<?php

namespace app\api\controller;

use app\common\controller\Api;
use EasyWeChat\Factory;
use app\api\controller\My;
use app\common\controller\MyHelp;
use think\Db;
use think\Cache;
use fast\Http;
use fast\Random;
use app\api\controller\Pay;
use app\api\controller\Image;
use app\admin\model\caiwu\Money as moneylog;

/**
 * 首页接口
 */
class Babaohui extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    /**
     * 获取系统配置
     */
    public function getCfg()
    {
        $ver = $this->request->request('ver');
        if ($ver == 7) {
            $shenhe = 1;
        } else {
            $shenhe = 0;
        }
        $data = [
            'gg' => '欢迎使用八宝汇寄快递平台',
            'shenhe' => $shenhe
        ];
        return $this->success('', $data);
    }
    public function geocoder()
    {
        $address = $this->request->request('address');
        $rst =  Http::get('https://apis.map.qq.com/ws/geocoder/v1/?address=' . $address . '&key=5UABZ-POTWL-FDVP6-MVZJK-WUV2O-53BSJ');
        $rst_arr = json_decode($rst, true);


        if ($rst_arr['status'] == '0') {
            $this->success('请求成功', $rst_arr['result']['location']);
        } else {
            $this->error($rst_arr['message']);
        }
    }


    /**
     * 同城闪送
     */
    public function tongcheng_ss()
    {
        $request = $this->request->post();
        return  Kuaidi::yy_tongcheng_ss($request);
    }
    public function kd_checkPrice()
    {
        if (!$this->request->post('senderCounty')) {
            return $this->error('发送地参数有误');
        }
        if (!$this->request->post('receiveCounty')) {
            return $this->error('接收地参数有误');
        }
        $request = $this->request->post();
        $rst =  Kuaidi::yy_checkPrice($request);
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] != '1') {
            return $this->error($rst_arr['message']);
        }
        if (isset($rst_arr['result']['originalPrice'])) {
            return $this->success('', $rst_arr['result']['originalPrice']);
        } else {
            return $this->success('', $rst_arr['result']);
        }
    }
    /**
     * 智能解析地址
     */
    public function getAiAddress()
    {
        $address = $this->request->request('address');
        $rst = Kuaidi::get_addressNew($address);
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] == 1) {
            return $this->success('解析成功，如果不能智能解析请手动改写', $rst_arr['data']);
        } else {
            return $rst;
        }
    }

    /**
     * 查询物流
     */
    public function Qdelivery()
    {
        $orderno = $this->request->request('orderno');
        $order =   db::table('fa_order_kd')->where('orderno', $orderno)->find();
        if (!$order) {
            $this->error('订单号不存在');
        }
        if (!$order['deliveryId']) {
            $this->error('该订单异常，有问题联系客服');
        }
        $rst = Kuaidi::Qdelivery($order['deliveryType'], $order['deliveryId']);
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] == 200) {
            return $this->success('ok', ['list' => $rst_arr['data'], 'courierName' => $order['courierName'], 'courierPhone' => $order['courierPhone'], 'pickUpCode' => $order['pickUpCode']]);
        } else {
            return $this->error($rst_arr['msg']);
        }
    }
    public function kdQPrice()
    {

        $token = $this->request->request('token'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }

        $u = Db::table('fa_user')->where('unionid', $token)->find();
        $kd_zk_add = '5'; //总控加价百分比
        if (!$u) {
            $this->error('用户不存在');
        }


        $request = $this->request->post();

        cache::set('request' . $u['id'], $request, 10 * 60);

        $rst = Kuaidi::yy_checkChannel($request);
        //return $rst;
        $rst_arr = json_decode($rst, true);

        if ($rst_arr['code'] != 1) {
            return $this->error($rst_arr['message']);
        }
        $data = [];
        foreach ($rst_arr['result'] as $key => $value) {
            $data[$key]['channel'] = $value['channel'];
            $data[$key]['channelId'] = $value['channelId'];
            $freight = $value['freight'];
            $freightNi = round($freight * 0.05, 2);
            $freight = round($freight * (1 + 0.05), 2);

            $data[$key]['freight'] = $freight;
            $data[$key]['freightNi'] = $freightNi;
            $data[$key]['freightInsured'] = $value['freightInsured'];
            $data[$key]['freightHaocai'] = $value['freightHaocai'];
            $data[$key]['totalFreight'] = $freight + $value['freightHaocai'] + $value['freightInsured'];

            $data[$key]['channelLogoUrl'] = $value['channelLogoUrl'];
            $data[$key]['originalPrice'] = $value['originalPrice'];
            $data[$key]['priceMore'] = $value['priceMore'];
            $data[$key]['tagType'] = $value['tagType'];
            $data[$key]['channelExplain'] = $value['channelExplain'];
            $data[$key]['appointTimes'] = $value['appointTimes'];
        }
        cache::set('price' . $u['id'], $data, 10 * 60);
        return $this->success('ok', $data);
    }
    /**
     * 快递订单列表
     */
    public function kd_orderList()
    {
        $token = $this->request->request('token'); //uniid
        //$page = $this->request->request('page'); //uniid
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        $statuss = $this->request->request('statuss'); //uniid
        if (!$u) {
            $this->error('用户不存在');
        }
        if ($statuss == '-1') {
            $order =  db::table('fa_kd_order')->order('id desc')->field(['id', 'statuss', 'senderCity', 'receiveCity', 'senderName', 'receiveName', 'createtime', 'price', 'weight', 'deliveryId', 'deliveryType', 'channelLogoUrl', 'courierName', 'courierPhone'])->where('user_id', $u['id'])->limit(50)->select();
        } else {
            //状态:-1=全部,5=待取件,6=运输中,7=已签收,8=拒收退回
            $order =  db::table('fa_kd_order')->order('id desc')->field(['id', 'statuss', 'senderCity', 'receiveCity', 'senderName', 'receiveName', 'createtime', 'price', 'weight', 'deliveryId', 'deliveryType', 'channelLogoUrl', 'courierName', 'courierPhone'])->where('statuss', $statuss)->where('user_id', $u['id'])->limit(50)->select();
        }

        return $this->success('', $order);
    }
    /**
     * 删除失效订单任务
     */
    public  function task_delOrder()
    {
        db::table('fa_kd_order')->where('createtime', '<', time() - 20 * 60)->where('statuss', '1')->delete();
        db::table('fa_hf_order')->where('createtime', '<', time() - 20 * 60)->where('statuss', '1')->delete();
        db::table('fa_kq_order')->where('createtime', '<', time() - 20 * 60)->where('statuss', '1')->delete();
        $this->tiquery();
        return 'ok';
    }
    public function kdSubOrder()
    {
        //         $r = '{
        // 	"sender": "杨ff",
        // 	"senderMobile": "18838000101",
        // 	"senderProvince": "四川省",
        // 	"senderCity": "成都市",
        // 	"senderCounty": "双流区",
        // 	"senderLocation": "天目中心3栋",
        // 	"receiver": "杨xx",
        // 	"receiverMobile": "18801010202",
        // 	"receiveProvince": "广东省",
        // 	"receiveCity": "东莞市",
        // 	"receiveCounty": "塘厦镇",
        // 	"receiveLocation": "高裕北路118号广东建隆实业2栋8楼",
        // 	"weight": "1",
        // 	"packageCount": "1",
        // 	"itemName": "键盘",
        // 	"billRemark": "无备注"
        // }';
        //         $rst = Kuaidi::yy_subOrder(json_decode($r, true));
        //         return  $rst;
        $token = $this->request->request('token'); //uniid
        $payType = $this->request->request('payType');
        $channelId = $this->request->request('channelId');
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }

        $u = Db::table('fa_user')->where('unionid', $token)->find();
        $kd_zk_add = '5'; //总控加价百分比
        if (!$u) {
            $this->error('用户不存在');
        }
        $request = cache::get('request' . $u['id']);

        $price_arr = cache::get('price' . $u['id']);
        if (!$price_arr) {
            $this->error('查询结果已失效，请重新查询渠道');
        }
        $price = '';
        foreach ($price_arr as $key => $value) {
            if ($channelId == $value['channelId']) {
                $price = $value;
                break;
            }
        }
        if (!$price) {
            $this->error('渠道查询失败，请重新查询渠道');
        }
        $totalFreight = $price['totalFreight']; //总运费
        $cb = $totalFreight - $price['freightNi']; //成本

        if ($payType == 2) { //余额支付
            if ($u['money'] < $totalFreight) {
                $this->error('余额不足，请充值');
            }
            $newmoney = round($u['money'] - $totalFreight, 2);
            Db::table('fa_user')->where('id', $u['id'])->update(['money' => $newmoney]);
            $log = [
                'user_id' => $u['id'],
                'money' => $totalFreight * -1,
                'before' => $u['money'],
                'after' => $newmoney,
                'memo' => '快递预付款',
                'createtime' => time()
            ];
            Db::table('fa_user_money_log')->insert($log);
            $sxf = round($totalFreight * 0.002, 2);
            $zz_lr = round($price['freightNi'] * 0.4, 2);
            $lirun = round($price['freightNi'] - $sxf - $zz_lr, 2);
        } elseif ($payType == 1) {
            $sxf = round($totalFreight * 0.006, 2);
            $zz_lr = round($price['freightNi'] * 0.3, 2);
            $lirun = round($price['freightNi'] - $sxf - $zz_lr, 2);
            $this->error('支付分维护中');
        }



        $orderno = 'KD' . date("Ymdhis")  . mt_rand(1000000, 99999999);
        $data = [
            'admin_id' => $u['admin_id'],
            'orderno' => $orderno,

            'cbprice' => $cb,
            'lirun' => $lirun,
            'zz_lr' => $zz_lr,
            'sxf' => $sxf,

            //  'status' => '1',
            'createtime' => time(),
            'user_id' => $u['id'],
            'payType' => $payType,
            'senderName' => $request['sender'],
            'senderMobile' => $request['senderMobile'],
            'senderProvince' => $request['senderProvince'],
            'senderCity' => $request['senderCity'],
            'senderDistrict' => $request['senderCounty'],
            'senderAddress' => $request['senderLocation'],
            'receiveName' => $request['receiver'],
            'price' => $totalFreight,
            //receiveMobile
            'receiveMobile' => $request['receiverMobile'],
            'receiveProvince' => $request['receiveProvince'],
            'receiveCity' => $request['receiveCity'],
            'receiveDistrict' => $request['receiveCounty'],
            'receiveAddress' => $request['receiveLocation'],
            'goods' => $request['itemName'],
            'packageCount' => $request['packageCount'],
            'weight' => $request['weight'],
            'statuss' => '2',

            'pickUpStartTime' => $this->request->request('pickUpStartTime'),
            'pickUpEndTime' => $this->request->request('pickUpEndTime'),
            'deliveryType' => $price['tagType'],
            'channelLogoUrl' => $price['channelLogoUrl'],
        ];
        db::table('fa_kd_order')->insert($data);
        cache::set($orderno, $request, 60 * 60);


        unset($request['payType']);
        unset($request['token']);
        $request['billRemark'] = $this->request->request('billRemark');
        if ($this->request->request('pickupStartTime')) {
            $request['pickupStartTime'] = $this->request->request('pickupStartTime');
            $request['pickupStopTime'] = $this->request->request('pickupStopTime');
        }

        // return json($request);
        $rst = Kuaidi::yy_subOrder($request);
        //  return  $rst;
        // return $rst;
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] != 1) {
            //失败 退钱
            $u = Db::table('fa_user')->where('id', $u['id'])->find();
            $newmoney = round($u['money'] + $totalFreight, 2);
            Db::table('fa_user')->where('id', $u['id'])->update(['money' => $newmoney]);
            $log = [
                'user_id' => $u['id'],
                'money' => $totalFreight,
                'before' => $u['money'],
                'after' => $newmoney,
                'memo' => '快递预付款退款',
                'createtime' => time()
            ];
            Db::table('fa_user_money_log')->insert($log);
            db::table('fa_kd_order')->where('orderno', $orderno)->update(['remark' => $rst_arr['message'], 'statuss' => '4']);
            return $this->error('下单失败：' . $rst_arr['message']);
        } else {
            $shopbill = $rst_arr['result']['shopbill'];
            $waybill = $rst_arr['result']['waybill'];
            db::table('fa_kd_order')->where('orderno', $orderno)->update(['deliveryId' => $waybill, 'api_order' => $shopbill]);
            return $this->success('下单成功');
        }

        // if ($rst_arr['code'] != 1) {
        //     return $this->error($rst_arr['message']);
        // }


    }
    /**
     * 取消订单
     */
    public  function kd_cancel()
    {
        $token = $this->request->request('token'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $orderid = $this->request->request('orderid');
        $order = db::table('fa_kd_order')->where('id', $orderid)->find();
        if (!$order) {
            $this->error('订单有误');
        }
        if ($order['user_id'] != $u['id']) {
            $this->error('订单有误');
        }
        $shopbill = $order['api_order'];
        //     return $shopbill;
        $rst =  Kuaidi::yy_CANCEL($shopbill);
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] != 1) {
            $this->error($rst_arr['message']);
        } else {
            return $this->success('取消成功');
        }
    }
    /**
     * 订单详情
     */
    public  function kd_orderDetail()
    {
        $token = $this->request->request('token'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $orderid = $this->request->request('id');
        $order = db::table('fa_kd_order')->where('id', $orderid)->find();
        if (!$order) {
            $this->error('订单有误');
        }
        if ($order['user_id'] != $u['id']) {
            $this->error('订单有误');
        }

        return $this->success('成功', $order);
    }
    /**
     * 查询价格
     */
    public  function kd_orderTrance()
    {
        $token = $this->request->request('token'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $orderid = $this->request->request('orderid');
        $order = db::table('fa_kd_order')->where('id', $orderid)->find();
        if (!$order) {
            $this->error('订单有误');
        }
        if ($order['user_id'] != $u['id']) {
            $this->error('订单有误');
        }
        $shopbill = $order['api_order'];
        $rst =  Kuaidi::yy_trance($shopbill);
        $rst_arr = json_decode($rst, true);
        if ($rst_arr['code'] != 1) {
            $this->error($rst_arr['message']);
        } else {
            return $this->success('成功', $rst_arr['result']);
        }
    }
    public function fff()
    {
        $request = '{"senderProvince":"\u6c5f\u82cf\u7701","senderCity":"\u5e38\u5dde\u5e02","senderDistrict":"\u6b66\u8fdb\u533a","senderName":"\u91d1\u6b22","senderAddress":"\u6e5f\u91cc\u9547 \u6843\u82d1\u65b0\u90fd16\u680b503","senderMobile":"18118395685","receiveProvince":"\u6c5f\u82cf\u7701","receiveCity":"\u8fde\u4e91\u6e2f\u5e02","receiveDistrict":"\u8d63\u6986\u533a","receiveName":"\u5218\u91d1\u864e","receiveAddress":"\u73ed\u5e84\u9547 \u5b59\u51c0\u6751","receiveMobile":"15267971883","packageCount":"1","weight":"1","goods":"\u6587\u4ef6","remark":"\u65e0","token":"ee1c37a2d49f7d063d90b9da89f995b8","username":"o-qMS6ZTli87QzPgRWvIWUWzPjyg","from":"2","customerType":"kd","thirdNo":"KD2022102210042729987535","admin_id":68,"openid":"o-qMS6ZTli87QzPgRWvIWUWzPjyg","user_id":442}';
        $rst = Kuaidi::suborder(json_decode($request, true));
        return  $rst;
    }
    /**
     * 微信支付分下单
     */
    public function zffOrder()
    {
    }
    /**
     * 团队粉丝
     */
    public  function groupUser()
    {
        $token = $this->request->request('token'); //uniid
        $type = $this->request->request('type', 1); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        if ($u['s_id'] > 0) {
            $u_s = Db::table('fa_user')->where('id', $u['s_id'])->find();
            $s_nickname = $u_s['nickname'];
        } else {
            $s_nickname = "";
        }
        if ($type == 1) {
            $user_s = Db::table('fa_user')->order('id desc')->field(['nickname', 'id', 'avatar', 'level', 'jointime', 'createtime'])->where('s_id', $u['id'])->limit(100)->select();
        } else {
            $user_s = Db::table('fa_user')->order('id desc')->where('level', 1)->field(['nickname', 'id', 'avatar', 'level', 'jointime', 'createtime'])->where('s_id', $u['id'])->limit(100)->select();
        }


        foreach ($user_s as $key => $value) {
            $fs_num = Db::table('fa_user')->where('s_id', $value['id'])->count('id');
            //状态:1=未付款,2=充值中,3=成功,4=失败退款,5=部分成功
            $order_num = Db::table('fa_hf_order')->where('statuss', 'in', '2,3,4,5')->where('user_id', $value['id'])->count('id');
            $user_s[$key]['fs_num'] = $fs_num;
            $user_s[$key]['order_num'] = $order_num;
        }
        $fansInfo['all'] = count($user_s);
        $fansInfo['s_nickname'] = $s_nickname;

        return $this->success('', ['userList' => $user_s, 'fansInfo' => $fansInfo]);
    }
    /**
     * h5公众号登录
     */
    public function wxLoginMp()
    {
        $code = $this->request->request("code");
        $key = $this->request->request("key");

        //  MyHelp::dingding('登录订单：' . json_encode($this->request->request()), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');

        $appid = "wx6a20a1300ba9e158";
        $screct = '59c34f438a350e30fc08c002276e752b';
        $from_id = $this->request->request("from_id");
        $rst =  http::get('https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $appid . '&secret=' . $screct . '&code=' . $code . '&grant_type=authorization_code');
        //   return $rst;
        $rst_arr = json_decode($rst, true);
        if (!isset($rst_arr['openid'])) {
            $this->error($rst_arr['errmsg']);
        }

        $openid = $rst_arr['openid'];
        $unionid =  $rst_arr['unionid'];
        //refresh_token
        $access_token =  $rst_arr['access_token'];
        $mp_refresh_token = $rst_arr['refresh_token'];
        if (isset($rst_arr['is_snapshotuse'])) {
            if ($rst_arr['is_snapshotuse'] == '1') {
                return $this->success('', ['unionid' => '', 'id' => '']);
            }
        }

        $rst =  http::get('https://api.weixin.qq.com/sns/userinfo?access_token=' . $access_token . '&openid=' . $openid . '&lang=zh_CN');
        $rst_arr = json_decode($rst, true);
        $nickname = $rst_arr['nickname'];
        $headimgurl = $rst_arr['headimgurl'];

        // $user = [
        //     'openid' => $openid,
        //     'unionid' => $unionid,
        //     'nickname' => $nickname,
        //     'headimgurl' => $headimgurl,
        // ];

        $user =  db::table('fa_user')->where('unionid', $unionid)->find();
        if (!$user) {
            $request = \think\Request::instance();
            $ip =  $request->ip();
            $r = $this->getIp($ip);
            if ($r) {
                if (!$r['region_id']) {
                    $pro = '';
                    $city = '';
                } else {
                    $pro = $r['region'];
                    $city = $r['city'];
                }
            } else {
                $pro = '';
                $city = '';
            }
            $admin =  db::table('fa_admin')->where('key', $key)->find();
            if ($admin) {
                $admin_id = $admin['id'];
            } else {
                $admin_id = 1;
            }
            // if ($from_id > 0) {
            //     $user_s =  db::table('fa_user')->where('id', $from_id)->find();
            //     if ($user_s['admin_id'] > 1) {
            //         $admin_id = $user_s['admin_id'];
            //     } else {
            //         $admin_id = 1;
            //     }
            // }
            $data = [
                'openid_mp' => $openid,
                'unionid' => $unionid,
                'admin_id' => $admin_id,
                //  'session_key_xcx' => $session_key,
                'nickname' => $nickname,
                //'avatar' => 'https://cdn.8nit.cn/uploads/20231217/daeae7bcc5b39b5a2d974e57f7facb5f.jpg',
                'createtime' => time(),
                'joinip' => $ip,
                's_id' => $from_id,
                'mp_refresh_token' => $mp_refresh_token,
                'avatar' => $headimgurl,
                'logintime' => time(),
                'pro' => $pro,
                'city' => $city,
            ];
            db::table('fa_user')->insert($data);
            $id = db::table('fa_user')->getLastInsID();
        } else {
            $request = \think\Request::instance();
            $ip =  $request->ip();

            $r = $this->getIp($ip);
            if ($r) {
                if (!$r['region_id']) {
                    $pro = '';
                    $city = '';
                } else {
                    $pro = $r['region'];
                    $city = $r['city'];
                }
            } else {
                $pro = '';
                $city = '';
            }
            $data = [
                'loginip' => $ip,
                'openid_mp' => $openid,
                'avatar' => $headimgurl,
                'nickname' => $nickname,
                'mp_refresh_token' => $mp_refresh_token,
                'logintime' => time(),
                'pro' => $pro,
                'city' => $city,
                //'session_key_xcx' => $session_key
            ];
            $admin =  db::table('fa_admin')->where('unionid', $unionid)->find();
            if ($admin) {
                $admin_id = $admin['id'];
                if ($user['admin_id'] != $admin_id) {
                    $data['admin_id'] = $admin_id;
                }
            }



            db::table('fa_user')->where('unionid', $unionid)->update($data);
            $id = $user['id'];
        }
        //  $rst_arr['id'] = $id;
        return $this->success('', ['unionid' => $unionid, 'id' => $id]);
    }
    /**
     * 小程序code登录
     */
    public  function xcxloginCode()
    {
        $code = $this->request->request('code');
        $key = $this->request->request('key');

        $rst_arr =  Wechat::xcxlogin($code);
        if (!isset($rst_arr['unionid'])) {
        }
        $openid = $rst_arr['openid'];
        $unionid =  $rst_arr['unionid'];
        $user =  db::table('fa_user')->where('unionid', $unionid)->find();
        if (!$user) {
            $request = \think\Request::instance();
            $ip =  $request->ip();
            $r = $this->getIp($ip);
            if ($r) {
                if (!$r['region_id']) {
                    $pro = '';
                    $city = '';
                } else {
                    $pro = $r['region'];
                    $city = $r['city'];
                }
            } else {
                $pro = '';
                $city = '';
            }
            $admin =  db::table('fa_admin')->where('key', $key)->find();
            if ($admin) {
                $admin_id = $admin['id'];
            } else {
                $admin_id = 1;
            }
            // if ($from_id > 0) {
            //     $user_s =  db::table('fa_user')->where('id', $from_id)->find();
            //     if ($user_s['admin_id'] > 1) {
            //         $admin_id = $user_s['admin_id'];
            //     } else {
            //         $admin_id = 1;
            //     }
            // }
            $data = [
                'openid_xcx1' => $openid,
                'unionid' => $unionid,
                'admin_id' => $admin_id,
                //  'session_key_xcx' => $session_key,
                'nickname' => $pro . '用户' . Random::alpha(4),
                'avatar' => 'https://cdn.8nit.cn/uploads/20231217/daeae7bcc5b39b5a2d974e57f7facb5f.jpg',
                'createtime' => time(),
                'joinip' => $ip,
                's_id' => 0,
                'mp_refresh_token' => 0,
                //  'avatar' => $headimgurl,
                'logintime' => time(),
                'pro' => $pro,
                'city' => $city,
            ];
            db::table('fa_user')->insert($data);
            $id = db::table('fa_user')->getLastInsID();
        } else {
            $request = \think\Request::instance();
            $ip =  $request->ip();

            $r = $this->getIp($ip);
            if ($r) {
                if (!$r['region_id']) {
                    $pro = '';
                    $city = '';
                } else {
                    $pro = $r['region'];
                    $city = $r['city'];
                }
            } else {
                $pro = '';
                $city = '';
            }
            $data = [
                'loginip' => $ip,
                'openid_xcx1' => $openid,
                'nickname' => $pro . '用户' . Random::alpha(4),
                'avatar' => 'https://cdn.8nit.cn/uploads/20231217/daeae7bcc5b39b5a2d974e57f7facb5f.jpg',
                // 'mp_refresh_token' => $mp_refresh_token,
                'logintime' => time(),
                'pro' => $pro,
                'city' => $city,
                //'session_key_xcx' => $session_key
            ];
            $admin =  db::table('fa_admin')->where('unionid', $unionid)->find();
            if ($admin) {
                $admin_id = $admin['id'];
                if ($user['admin_id'] != $admin_id) {
                    $data['admin_id'] = $admin_id;
                }
            }



            db::table('fa_user')->where('unionid', $unionid)->update($data);
            $id = $user['id'];
        }
        return $this->success('', $rst_arr);
    }
    /**
     * 微信code登录
     */
    public function wxLogin()
    {
        $code = $this->request->request("code");
        $key = $this->request->request("key");
        $from_id = $this->request->request("from_id");
        $appid = "wx2f396da944f64fe8";
        $screct = '2e5dae07eb747777abb25b07c293c000';
        $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appid . "&secret=" . $screct . "&js_code=" . $code . "&grant_type=authorization_code";

        $rst = http::get($url);
        //  return $rst;
        $rst_arr = json_decode($rst, true);
        if (!isset($rst_arr['openid'])) {
            return $this->error('请重新登录,重新刷新code');
        }
        $openid =  $rst_arr['openid'];
        $unionid =  $rst_arr['unionid'];
        $session_key =  $rst_arr['session_key'];

        $user =  db::table('fa_user')->where('unionid', $unionid)->find();
        if ($key) {
            $admin =  db::table('fa_admin')->where('key', $key)->find();
            if ($admin) {
                $admin_id = $admin['id'];
            } else {
                $admin_id = 1;
            }
        } else {
            $admin_id = 1;
        }


        if (!$user) {
            $request = \think\Request::instance();
            $ip =  $request->ip();
            $r = $this->getIp($ip);
            if ($r) {
                if (!$r['region_id']) {
                    $pro = '';
                    $city = '';
                } else {
                    $pro = $r['region'];
                    $city = $r['city'];
                }
            } else {
                $pro = '';
                $city = '';
            }
            $data = [
                'openid_xcx' => $openid,
                'unionid' => $unionid,
                'admin_id' => $admin_id,
                'session_key_xcx' => $session_key,
                'nickname' => $pro . '用户' . Random::alpha(4),
                'avatar' => 'https://cdn.8nit.cn/uploads/20231217/daeae7bcc5b39b5a2d974e57f7facb5f.jpg',
                'createtime' => time(),
                'joinip' => $ip,
                's_id' => $from_id
            ];
            db::table('fa_user')->insert($data);
            $id = db::table('fa_user')->getLastInsID();
        } else {
            $request = \think\Request::instance();
            $ip =  $request->ip();
            $data = [
                'loginip' => $ip,
                'openid_xcx' => $openid,
                'session_key_xcx' => $session_key
            ];
            db::table('fa_user')->where('unionid', $unionid)->update($data);
            $id = $user['id'];
        }
        $rst_arr['id'] = $id;
        return $this->success('', $rst_arr);
    }
    /**
     * 获取ip归属地
     */
    public  function getIp($ip = '223.91.190.101')
    {
        if (Cache::has('gsd_' . $ip)) {
            return Cache::get('gsd_' . $ip);
        }
        $headers = ['Authorization: APPCODE 575b6b88f3204af58c1118ce8223139e'];
        $options = [
            CURLOPT_HTTPHEADER => $headers
        ];
        // {"data":{"ip":"125.44.76.122","long_ip":"2100055162","isp":"联通","area":"华中","region_id":"410000","region":"河南","city_id":"411100","city":"漯河","country_id":"CN","country":"中国"},"ret":200,"msg":"success","log_id":"13bbdcc0460a46ec85305320a993c832"}
        $r = http::get('https://api01.aliyun.venuscn.com/ip?ip=' . $ip, [], $options);
        //   return $r;
        $r_arr = json_decode($r, true);
        if ($r_arr['ret'] == 200) {
            Cache::set('gsd_' . $ip, $r_arr['data']);
            return $r_arr['data'];
        } else {
            return  false;
        }
    }
    /**
     * 获取话费面值
     */
    public function hf_getMz()
    {
        $type = $this->request->request('type');
        $shop_key = $this->request->request('key');
        $mobile = $this->request->request('mobile');
        if ($mobile) {
            $mobile = str_replace(' ', '', $mobile);
            $mobileInfo = $this->getYys1($mobile);
            $mobileInfo_arr = json_decode($mobileInfo, true);
            if (!isset($mobileInfo_arr['result']['Province'])) {
                return $this->error('系统异常或手机号有误');
            }
            $Province = $mobileInfo_arr['result']['Province'];

            $City = $mobileInfo_arr['result']['City'];
            $Isp = $mobileInfo_arr['result']['Isp'];
            if ($Isp == '中国移动') {
                $yys = '1';
            } elseif ($Isp == '中国联通') {
                $yys = '2';
            } elseif ($Isp == '中国电信') {
                $yys = '3';
            } else {
                $this->error('不支持的运营商');
            }
        } else {
            $mobileInfo = '';
        }
        if (!$shop_key) {
            $this->error('系统错误，链接配置失败');
        }
        $admin =  db::table('fa_admin')->where('key', $shop_key)->find();
        if ($admin) {
            $admin_id = $admin['id'];
            $kf_url = $admin['kf_url'];
        } else {
            $this->error('系统错误，链接配置失败');
        }

        //{"code": 0,"reason": "Succ","result": {"Mobile": "18838000395","Province": "河南","City": "郑州","Isp": "中国移动"}}
        $goods = db::table('fa_hf_goods')->where('type', $type)->where('statuss', '1')->order('weigh desc')->field(['id', 'mz', 'title', 'cb', 'price', 'type', 'yys', 'forbid'])->select();

        foreach ($goods as $key => $value) {
            $zzzz =  MyHelp::getPriceNew($admin, $value['id']); //直接推广者
            // $goods[$key]['price'] = $zzzz['price'];
            $goods[$key]['price'] = $zzzz['price_h5']; //
            $goods[$key]['cb'] = 0;
            // $goods[$key]['price_hhr'] = round($value['price'] - $value['mz'] / 100, 1);
        }


        if ($mobileInfo) {
            $goods1 = [];
            foreach ($goods as $key => $value) {

                if ($value['yys'] == 1 && $Isp == '中国移动' && !MyHelp::strexists($value['forbid'], $Province)) {
                    $goods1[] = $value;
                } elseif ($value['yys'] == 2 && $Isp == '中国联通' && !MyHelp::strexists($value['forbid'], $Province)) {
                    $goods1[] = $value;
                } elseif ($value['yys'] == 3 && $Isp == '中国电信' && !MyHelp::strexists($value['forbid'], $Province)) {
                    $goods1[] = $value;
                }
            }
            return $this->success('ok', ['goods' => $goods1, 'mobileInfo' => str_replace('中国', '', $Province . $Isp), 'kf_url' => $kf_url]);
        } else {
            return $this->success('ok', ['goods' => $goods, 'mobileInfo' => $mobileInfo, 'kf_url' => $kf_url]);
        }
    }
    public function getYys1($mobile = '18132828678')
    {
        // $mobile = $this->request->request('mobile');

        if (Cache::has('getYys2' . $mobile)) {
            $r = Cache::get('getYys2' . $mobile);
        } else {
            $r = http::get('http://47.111.177.60:6006/isp_area?apikey=E71484279FBE45B7B0202BBFC7729DA4&mobile=' . $mobile);
            Cache::set('getYys2' . $mobile, $r, 7 * 24 * 60 * 60);
        }
        return  $r;
    }
    /**
     * 付款回调
     */
    public function payCallback($pro)
    {
        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';
        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',
            // 'mch_id' => '1615197849',
            'mch_id' => '1667355144',


            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        if ($pro == 'hf') {

            $response = $app->handlePaidNotify(function ($message, $fail) {
                // 你的逻辑
                //{"appid":"wx6a20a1300ba9e158","bank_type":"OTHERS","cash_fee":"100","fee_type":"CNY","is_subscribe":"N","mch_id":"1615197849","nonce_str":"6592e86653655","openid":"oEz4X6Xstlk8Yn1B7R8sc9qfe7B4","out_trade_no":"HF2024010212292615827089","result_code":"SUCCESS","return_code":"SUCCESS","sign":"5ADA3C4AE92181C3FC68F28B0055C901","time_end":"20240102002930","total_fee":"100","trade_type":"JSAPI","transaction_id":"4200002108202401029435621231"}
                // MyHelp::dingding('话费订单传参：' . json_encode($message), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');

                $out_trade_no = $message['out_trade_no'];
                $order = Db::table('fa_hf_order')->where('orderno', $out_trade_no)->find();
                if ($order) {
                    if ($order['statuss'] != '1') {
                        return true;
                    }
                    //四川湖南电信 走另外的
                    $rst =  $this->addOrderHF1($out_trade_no, $order['account'], $order['code'], $order['cztype'], $order['api']);

                    if ($rst['code'] == 1) {
                        Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['statuss' => '2', 'remark' => '充值中', 'api_order' => $rst['order']]);
                        //分佣
                        $fy = json_decode($order['lr_arr'], true);
                        foreach ($fy as $key => $value) {
                            if ($value['id'] > 0) {
                                $fenyong = [
                                    'admin_id' => $value['id'],
                                    'orderNo' => $out_trade_no,
                                    'memo' => '订单分佣：' . $order['title'],
                                    'createtime' => time(),
                                    'money' => $value['money']
                                ];
                                Db::table('fa_fenyong')->insert($fenyong);
                            }
                        }
                    } else {
                        Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['statuss' => '4', 'remark' => '失败退款' . $rst['msg'], 'ccccc' => 100]);
                        $rst_refund =  $this->refund($out_trade_no, $order['price'], 100, '失败退款');
                        if ($rst_refund['return_code'] == 'SUCCESS') {
                            if ($rst_refund['result_code'] == 'SUCCESS') {
                                Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '1', 'refundrst' => '退款成功']);
                            } else {
                                Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '2', 'refundrst' => '退款失败:' . $rst_refund['err_code_des']]);
                            }
                        } else {
                            Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '2', 'refundrst' => '退款失败:' . $rst_refund['return_msg']]);
                        }
                    }
                }
                return true;
            });
        } elseif ($pro == 'yue') {
            $response = $app->handlePaidNotify(function ($message, $fail) {
                // 你的逻辑
                $out_trade_no = $message['out_trade_no'];
                $order = Db::table('fa_user_money_cz')->where('orderno', $out_trade_no)->find();
                if ($order) {
                    if ($order['statuss'] != '1') {
                        return true;
                    }
                    Db::table('fa_user_money_cz')->where('orderno', $out_trade_no)->update(['statuss' => '3']);
                    $user = Db::table('fa_user')->where('id', $order['user_id'])->find();
                    $newmoney = round($user['money'] + $order['money'], 2);
                    Db::table('fa_user')->where('id', $order['user_id'])->update(['money' => $newmoney]);
                    $log = [
                        'user_id' => $order['user_id'],
                        'money' => $order['money'],
                        'before' => $user['money'],
                        'after' => $newmoney,
                        'memo' => '余额充值',
                        'createtime' => time()
                    ];
                    Db::table('fa_user_money_log')->insert($log);
                }
                return true;
            });
        } elseif ($pro == 'hhr') {
            $response = $app->handlePaidNotify(function ($message, $fail) {
                // 你的逻辑
                $out_trade_no = $message['out_trade_no'];
                $order = Db::table('fa_user_upgrade')->where('orderno', $out_trade_no)->find();
                if ($order) {
                    if ($order['statuss'] != '0') {
                        return true;
                    }

                    Db::table('fa_user_upgrade')->where('orderno', $out_trade_no)->update(['statuss' => '1', 'payttime' => time()]);
                    $user = Db::table('fa_user')->where('id', $order['user_id'])->find();

                    if ($order['type'] == 1) {
                        if ($user['level2_endtime'] == 0 || $user['level2_endtime'] < time()) {
                            $end = time() + 30 * 24 * 60 * 60;
                        } else {
                            $end = $user['level2_endtime'] + 30 * 24 * 60 * 60;
                        }
                    } else {
                        $end = -1;
                    }

                    Db::table('fa_user')->where('id', $order['user_id'])->update(['level' => '1', 'level2_endtime' => $end]);
                    //算提成
                    if ($user['s_id'] > 0) {
                        $s = Db::table('fa_user')->where('id', $user['s_id'])->find();
                        if ($s['level'] == 1) { //上级是合伙人
                            if ($order['type'] == 1) { //按月付 
                                $money_jl = 5; //一半奖励
                            } else {
                                $money_jl = 50; //一半奖励
                            }
                        } else {
                            if ($order['type'] == 1) { //按月付 
                                $money_jl = 2; //一半奖励
                            } else {
                                $money_jl = 20; //一半奖励
                            }
                        }
                        $newmoney = round($money_jl + $s['money'], 2);
                        $log = [
                            'user_id' => $s['id'],
                            'money' => $money_jl,
                            'before' => $s['money'],
                            'after' => $newmoney,
                            'memo' => '用户升级推广奖励',
                            'createtime' => time(),
                            'type' => '2'
                        ];
                        //类型:1=余额充值,2=佣金收入,3=提现,4=消费
                        Db::table('fa_user_money_log')->insert($log);
                        Db::table('fa_user')->where('id', $order['user_id'])->update(['money' => $newmoney]);
                    }
                }
                return true;
            });
        }
        $response->send(); // Laravel 里请使用：return $response;
    }
    /**
     * 添加地址
     */
    public function addAddress()
    {
        $token = $this->request->request('token'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $data = [
            'user_id' => $u['id'],
            'admin_id' => $u['admin_id'],
            'province' => $this->request->request('province'),
            'city' => $this->request->request('city'),
            'district' => $this->request->request('district'),
            'address' => $this->request->request('address'),
            'name' => $this->request->request('name'),
            'type' => $this->request->request('type'),
            'mobile' => $this->request->request('mobile')
        ];
        Db::table('fa_kd_address')->insert($data);
        return $this->success('添加成功');
    }
    /**
     * 用户信息
     */
    public function getUserInfo()
    {
        $token = $this->request->request('token'); //uniid
        $type = $this->request->request('type');
        $u = Db::table('fa_user')->field(['nickname', 'id', 'mobile', 'avatar', 'money', 'createtime', 'level2_endtime', 'level'])->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $sy_today = Db::table('fa_user_money_log')->where('user_id', $u['id'])->whereTime('createtime', 'today')->where('type', '2')->sum('money');
        $sy_yes = Db::table('fa_user_money_log')->where('user_id', $u['id'])->whereTime('createtime', 'yesterday')->where('type', '2')->sum('money');
        $sy_all = Db::table('fa_user_money_log')->where('user_id', $u['id'])->where('type', '2')->sum('money');
        $user_num = Db::table('fa_user')->where('s_id', $u['id'])->count('id');
        $u['sy_today'] = $sy_today;
        $u['sy_yes'] = $sy_yes;
        $u['sy_all'] = $sy_all;
        $u['user_num'] = $user_num;
        return $this->success('', $u);
    }
    /**
     * 地址列表
     */
    public function addressList()
    {
        $token = $this->request->request('token'); //uniid
        $type = $this->request->request('type');
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        if ($type == '-1') {
            $order =   Db::table('fa_kd_address')->where('user_id', $u['id'])->order('id desc')->select();
        } else {
            $order =   Db::table('fa_kd_address')->where('type', $type)->where('user_id', $u['id'])->order('id desc')->select();
        }

        return $this->success('ok', $order);
    }

    /**
     * 地址详情
     */
    public function getAddresDetail()
    {
        $token = $this->request->request('token'); //uniid
        $addressid = $this->request->request('addressid');
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $order =   Db::table('fa_kd_address')->where('id', $addressid)->find();
        if ($order['user_id'] != $u['id']) {
            $this->error('地址id有误');
        }

        return $this->success('成功', $order);
    }
    /**
     * 删除地址
     */
    public function delAddres()
    {
        $token = $this->request->request('token'); //uniid
        $addressid = $this->request->request('addressid');
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $order =   Db::table('fa_kd_address')->where('id', $addressid)->find();
        if ($order['user_id'] != $u['id']) {
            $this->error('地址id有误');
        }
        Db::table('fa_kd_address')->where('id', $addressid)->delete();

        return $this->success('删除成功');
    }
    /**
     * 修改地址
     */
    public function editAddress()
    {
        $token = $this->request->request('token'); //uniid
        $addressid = $this->request->request('addressid');
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $order =   Db::table('fa_kd_address')->where('id', $addressid)->find();
        if ($order['user_id'] != $u['id']) {
            $this->error('地址id有误');
        }
        $data = [
            'user_id' => $u['id'],
            'admin_id' => $u['admin_id'],
            'province' => $this->request->request('province'),
            'city' => $this->request->request('city'),
            'district' => $this->request->request('district'),
            'address' => $this->request->request('address'),
            'name' => $this->request->request('name'),
            'mobile' => $this->request->request('mobile')
        ];
        Db::table('fa_kd_address')->where('id', $addressid)->update($data);
        return $this->success('修改成功');
    }
    /**
     * 用户余额明细
     */
    public function userMoneyLog()
    {
        $token = $this->request->request('token'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $order = Db::table('fa_user_money_log')->where('user_id', $u['id'])->order('id desc')->limit(50)->select();
        return $this->success('ok', $order);
    }
    /**
     * 退款流程
     */
    public  function refund($out_trade_no, $money, $bl, $remark = '失败退款')
    {
        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';
        $order = Db::table('fa_hf_order')->where('orderno', $out_trade_no)->find();
        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',

            'mch_id' => '1667355144',
            //  'mch_id' => '1615197849',
            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        $result = $app->refund->byOutTradeNumber($out_trade_no, $out_trade_no . 'refund', $order['price'] * 100, $money * 100, [
            // 可在此处传入其他参数，详细参数见微信支付文档
            'refund_desc' => $remark,
        ]);
        return $result;
    }

    public  function getPhoneNumber()
    {
        $token = $this->request->request('token'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $code = $this->request->request('code');

        $config = [
            'app_id'   => 'wx2f396da944f64fe8',
            'secret'   => '2e5dae07eb747777abb25b07c293c000',
            //'response_type' => 'object',
            // 'token' => 'f1c242gdfhggfhghgh',
            // 'aes_key' => 'hPM9UCsg3Oie1yHeuO821z3DRhQBmYnFigLY1D23csk',
        ];
        $app = Factory::miniProgram($config);
        $response = $app->httpPostJson('/wxa/business/getuserphonenumber', [
            "code" => $code,
        ]);
        if ($response['errcode'] == '0') {
            $mobile = $response['phone_info']['purePhoneNumber'];
            Db::table('fa_user')->where('unionid', $token)->update(['mobile' => $mobile]);
            return $this->success('', ['mobile' => $mobile]);
        } else {
            return $this->error($response['errmsg']);
        }

        return $response;
        //$decryptedData = $app->encryptor->decryptData($session, $iv, $encryptedData);
        // return $app->auth->session($code);
    }
    /**
     * 话费回调
     */
    public function hfCallback()
    {
        //https://oapi.dingtalk.com/robot/send?access_token=3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6
        MyHelp::dingding('话费订单回调：' . json_encode($this->request->request()), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
        $status = $this->request->request('state');
        $charge_amount = $this->request->request('charge_amount');
        // $remark = $this->request->request('remark');
        $out_trade_num = $this->request->request('out_trade_num');
        $order = Db::table('fa_hf_order')->where('orderno', $out_trade_num)->find();
        if ($order) {
            if ($order['statuss'] != '2') { //已处理过
                return 'success';
            }
            if ($status == '1') {
                $remark = '充值成功';
                $zt = '3';
                MyHelp::dingding('话费订单回调：' . '充值成功', '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            } elseif ($status == '-1' || $status == '2') {
                $zt = '4';
                $remark = '充值失败';
                MyHelp::dingding('话费订单回调：' . '充值失败', '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            } elseif ($status == '3') { //部分到账
                $zt = '5';
                $out_trade_no = $out_trade_num;
                $zzlr = round($charge_amount / $order['mz'] * $order['zzlr'], 2);
                $bl = round(1 - $charge_amount / $order['mz'], 2); //退款比例
                $money = round($bl * $order['price'], 2); //退款金额
                Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['statuss' => '5', 'remark' => '部分充值退款比例[' . $bl . ']', 'ccccc' => $bl, 'zzlr' => $zzlr, 'update_time' => time()]);
                //比如200面值 付款184 成本182 站长利润1 原利润 184-1-182-0.4=0.6元
                //到账100 退100 

                return 'success'; //部分到账单独写逻辑
            } else {
                return 'success';
            }
            //状态:1=未付款,2=充值中,3=成功,4=失败退款,5=部分成功
            if ($zt == 3) { //成功 分钱
                Db::table('fa_hf_order')->where('orderno', $out_trade_num)->update(['statuss' => $zt, 'remark' => $remark, 'update_time' => time()]);
                if ($order['from'] == 2) { //后台

                } elseif ($order['from'] == 1) {
                } else {
                    //api
                    $data = [
                        'orderno' => $out_trade_num,
                        'status' => $zt,
                    ];
                    $t =   Http::post($order['notifyUrl'], $data);
                    $t = substr($t, 0, 100);
                    $data1['notifyRst'] = $t;
                    Db::table('fa_hf_order')->where('orderno', $out_trade_num)->update($data1);
                }
                Db::table('fa_fenyong')->where('orderNo', $out_trade_num)->update(['statuss' => '2', 'endtime' => time()]);
                $lr_arr = json_decode($order['lr_arr'], true); //利润

                foreach ($lr_arr as $key => $value) {
                    if ($value['id'] > 0) {
                        $admin = db::table('fa_admin')->where('id', $value['id'])->find();
                        $before = $admin['money'];
                        $new_money = round($before + $value['money'], 2);
                        db::table('fa_admin')->where('id', $value['id'])->update(['money' => $new_money]);

                        Moneylog::create(['admin_id' => $value['id'], 'type' => '3', 'money' => $value['money'], 'before' => $before, 'after' => $new_money, 'memo' => '订单佣金：' . $order['title'], 'type1' => 2, 'orderPc' => $out_trade_num]);
                    }
                }
            }
            if ($zt == 4) { //失败全部退款

                Db::table('fa_fenyong')->where('orderNo', $out_trade_num)->update(['statuss' => '3', 'endtime' => time()]);

                Db::table('fa_hf_order')->where('orderno', $out_trade_num)->update(['statuss' => $zt, 'remark' => $remark, 'update_time' => time()]);
                $out_trade_no = $out_trade_num;
                if ($order['from'] == 2) {
                    $admin = db::table('fa_admin')->where('id', $order['admin_id'])->find();
                    $before = $admin['money'];

                    $new_money = round($before + $order['price'], 2);
                    Moneylog::create(['admin_id' => $order['admin_id'], 'type' => '4', 'money' => $order['price'], 'before' => $before, 'after' => $new_money, 'memo' => '后台下单退款', 'type1' => 2, 'orderPc' => $out_trade_num]);

                    db::table('fa_admin')->where('id', $order['admin_id'])->update(['money' => $new_money]);
                } elseif ($order['from'] == 1) { //h5
                    $rst_refund =  $this->refund($out_trade_no, $order['price'], 100, '订单退款');
                    if ($rst_refund['return_code'] == 'SUCCESS') {
                        if ($rst_refund['result_code'] == 'SUCCESS') {
                            Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '1', 'refundrst' => '退款成功']);
                        } else {
                            Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '2', 'refundrst' => '退款失败:' . $rst_refund['err_code_des']]);
                        }
                    } else {
                        Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update(['refundrsts' => '2', 'refundrst' => '退款失败:' . $rst_refund['return_msg']]);
                    }
                } else {
                    $data = [
                        'orderno' => $out_trade_num,
                        'status' => $zt,
                    ];
                    if ($order['notifyUrl']) {
                        $t =   Http::post($order['notifyUrl'], $data);
                        $t = substr($t, 0, 100);
                        $data1['notifyRst'] = $t;
                        Db::table('fa_hf_order')->where('orderno', $out_trade_no)->update($data1);
                    }
                }
            }
        }
        return 'success';
    }

    /**
     * 提交到api
     */
    public function addOrderHF1($partner_order_no = '2022101406374213331985', $account = '18838000395', $product_id = 20, $mc = 1, $api)
    {
        //$partner_order_no = '2022101406374213331985', $account = '15566939833', $amount = 200, $type = '0'
        if ($api == 1) {
            $url = 'http://101.34.252.167/yrapi.php/index/recharge';
            $partner_id = '153';
            $key = '1E13FAEACD254DF74EA333860DB19387';
        } elseif ($api == 2) {
            $url = 'http://djcz.fliten.com/yrapi.php/index/recharge';
            $partner_id = '442';
            $key = 'D57C4C60AB0C13930AEC80C5ED67F379';
        }

        // $url = 'http://1.12.238.218/yrapi.php/index/recharge';
        // $partner_id = '12527';

        // $key = '01D604A3AAD33AE0206A67950C5F3E7D';

        $notify_url = 'https://mch.8nit.cn/api/babaohui/hfCallback';

        //运营商:1=移动,2=联通,3=电信

        $data = [
            'userid' => $partner_id,
            'out_trade_num' => $partner_order_no,
            'mobile' => $account,
            // 'amount' => $amount,
            'product_id' => $product_id,
            // 'charge_type' => $type, //充值类型，0联通，1电信，2移动
            'notify_url' => $notify_url
        ];
        ksort($data);
        //拼接签名串
        $sign_str = http_build_query($data) . '&apikey=' . $key;
        //签名

        // $api_rst = [
        //     'code' => 1,
        //     'msg' => '成功',
        //     'order' => 'test'
        // ];
        // return $api_rst;

        $sign = strtoupper(md5(urldecode($sign_str)));
        $data['sign'] = $sign;
        $rst = http::post($url, $data);
        //{"errno":0,"errmsg":"提交成功","data":{"id":358531,"order_number":"ZYC231217358531","mobile":"18838000395","product_id":20,"total_price":"91.50","create_time":1702821949,"guishu":"河南郑州","title":"旗舰移动100话费充值","out_trade_num":"2022101406374213331985"}}
        // return $rst;
        //{"errno":1,"errmsg":"省份在限制范围！","data":[]}
        $rst_arr = json_decode($rst, true);
        if (isset($rst_arr['errno'])) {
            if ($rst_arr['errno'] == '0') {
                $api_rst = [
                    'code' => 1,
                    'msg' => '成功',
                    'order' => $rst_arr['data']['order_number']
                ];
            } else {
                MyHelp::dingding('话费订单传参：' . json_encode($data), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
                MyHelp::dingding('话费订单结果：' . $rst, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
                $api_rst = [
                    'code' => 0,
                    'msg' => $rst_arr['errmsg'],
                    'order' => ''
                ];
            }
        } else {
            MyHelp::dingding('话费订单传参：' . json_encode($data), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            MyHelp::dingding('话费订单结果：' . $rst, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            $api_rst = [
                'code' => 0,
                'msg' => '异常！！！',
                'order' => ''
            ];
        }

        return $api_rst;
    }
    /**
     * 提交到api 接口2
     */
    public function addOrderHF2($partner_order_no = '2022101406374213331985', $account = '18838000395', $product_id = 20, $mc = 1)
    {
        //$partner_order_no = '2022101406374213331985', $account = '15566939833', $amount = 200, $type = '0'

        $url = 'http://djcz.fliten.com/yrapi.php/index/recharge';
        $partner_id = '405';

        $key = 'C83611E425B17316545C0D67B35C9ABD';


        $notify_url = 'https://mch.8nit.cn/api/babaohui/hfCallback';

        //运营商:1=移动,2=联通,3=电信

        $data = [
            'userid' => $partner_id,
            'out_trade_num' => $partner_order_no,
            'mobile' => $account,
            // 'amount' => $amount,
            'product_id' => $product_id,
            // 'charge_type' => $type, //充值类型，0联通，1电信，2移动
            'notify_url' => $notify_url
        ];
        ksort($data);
        //拼接签名串
        $sign_str = http_build_query($data) . '&apikey=' . $key;
        //签名
        $sign = strtoupper(md5(urldecode($sign_str)));
        $data['sign'] = $sign;
        $rst = http::post($url, $data);
        //{"errno":0,"errmsg":"提交成功","data":{"id":358531,"order_number":"ZYC231217358531","mobile":"18838000395","product_id":20,"total_price":"91.50","create_time":1702821949,"guishu":"河南郑州","title":"旗舰移动100话费充值","out_trade_num":"2022101406374213331985"}}
        // return $rst;
        //{"errno":1,"errmsg":"省份在限制范围！","data":[]}
        $rst_arr = json_decode($rst, true);
        if (isset($rst_arr['errno'])) {
            if ($rst_arr['errno'] == '0') {
                $api_rst = [
                    'code' => 1,
                    'msg' => '成功',
                    'order' => $rst_arr['data']['order_number']
                ];
            } else {
                MyHelp::dingding('话费订单传参：' . json_encode($data), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
                MyHelp::dingding('话费订单结果：' . $rst, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
                $api_rst = [
                    'code' => 0,
                    'msg' => $rst_arr['errmsg'],
                    'order' => ''
                ];
            }
        } else {
            MyHelp::dingding('话费订单传参：' . json_encode($data), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            MyHelp::dingding('话费订单结果：' . $rst, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
            $api_rst = [
                'code' => 0,
                'msg' => '异常！！！',
                'order' => ''
            ];
        }

        return $api_rst;
    }
    /**
     * 话费订单列表
     */
    public function hf_orderList()
    {
        $token = $this->request->request('token'); //uniid
        $statuss = $this->request->request('statuss'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        if ($statuss == '-1') {
            $order = Db::table('fa_hf_order')->where('user_id', $u['id'])->order('id desc')->field(['id', 'orderno', 'account', 'statuss', 'createtime', 'mz', 'yys', 'price', 'charge_amount', 'remark', 'image', 'title', 'update_time'])->limit(50)->select();
        } else {
            $order = Db::table('fa_hf_order')->where('statuss', $statuss)->where('user_id', $u['id'])->order('id desc')->field(['id', 'orderno', 'account', 'statuss', 'createtime', 'mz', 'yys', 'price', 'charge_amount', 'remark', 'image', 'title', 'update_time'])->limit(50)->select();
        }
        //状态:1=未付款,2=充值中,3=成功,4=失败退款,5=部分成功
        foreach ($order as $key => $value) {
            if ($value['statuss'] == '2') {
                $order[$key]['update_time'] = time();
            }
        }
        return $this->success('', $order);
    }
    public function getHaibao()
    {

        $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }


        $user_id = $u['id'];
        $hb = [];
        // $hb_user_num = Db::table('fa_haibao_user')->where('user_id', $user_id)->count('id');
        $hb = [
            [
                'id' => 1,
                'image' => 'https://cdn.8nit.cn/uploads/20240102/de5e256c0d8840e22bf9d9aed53ce6f8.jpg'
            ],
            [
                'id' => 2,
                'image' => 'https://cdn.8nit.cn/uploads/20240102/cd89fd2797c95f047372346d6409b64c.png'
            ],
        ];
        //  return json($hb);
        foreach ($hb as $key => $value) {
            $hb_arr[] = $value['id'];
            $hbuser = Db::table('fa_haibao_user')->where('user_id', $user_id)->where('hb_id', $value['id'])->find();
            if (!$hbuser) {
                $url = 'https://hf.8nit.cn/?from_id=' . $user_id;
                $image = new image();
                $url = $image->waimai($url, $value['image']);
                Db::table('fa_haibao_user')->insert(['hb_id' => $value['id'], 'user_id' => $user_id, 'hb_url' => 'https://mch.8nit.cn' . $url, 'createtime' => time()]);
            }
        }
        $hb_list = Db::table('fa_haibao_user')->where('hb_id', 'in', $hb_arr)->where('user_id', $user_id)->select();
        // foreach ($hb_list as $key => $value) {
        //     $hb_list[$key]['hb_url'] = cdnurl($value['hb_url'], true);
        // }
        return $this->success('ok', $hb_list);
    }
    /**
     * 话费提交订单
     */
    public function hf_subOrder()
    {
        $account = $this->request->request('account');
        $goodsid = $this->request->request('goodsid');
        $token = $this->request->request('token'); //uniid
        // MyHelp::dingding('话费订单传参：' . json_encode($this->request->request()), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
        $key = $this->request->request('key'); //1小程序 2公众号h5
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $goods = Db::table('fa_hf_goods')->where('id', $goodsid)->find();
        if (!$goods) {
            $this->error('商品有误');
        }
        $this->error('月初话费充值高峰期，到账速度比较慢，如有需要，请在10号后进行充值。');
        if ($goods['type'] == 2) {
            // $this->error('快充维护中，特惠充值速度也很快哦');
        }
        $account = str_replace(' ', '', $account);
        $mobileInfo = $this->getYys1($account);
        $mobileInfo_arr = json_decode($mobileInfo, true);
        if (!isset($mobileInfo_arr['result']['Province'])) {
            return $this->error('系统异常或手机号有误');
        }

        $Province = $mobileInfo_arr['result']['Province'];
        $City = $mobileInfo_arr['result']['City'];
        $Isp = $mobileInfo_arr['result']['Isp'];
        if ($Isp == '中国移动') {
            $yys = '1';
            $image = 'https://cdn.8nit.cn/uploads/20240101/eb0722ebcea3427f48c4dd8fada552a1.png';
        } elseif ($Isp == '中国联通') {
            $yys = '2';
            $image = 'https://cdn.8nit.cn/uploads/20240101/a09d4985e64f735f69f51dfe7e13d1be.png';
        } elseif ($Isp == '中国电信') {
            $yys = '3';
            $image = 'https://cdn.8nit.cn/uploads/20240101/fce2efbd9e7765b73cd9aed2cb6ea839.png';
        } else {
            $this->error('不支持的运营商');
        }

        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $orderno = 'HF' . date("Ymdhis")  . mt_rand(1000000, 99999999);
        $admin =  db::table('fa_admin')->where('key', $key)->find();
        if ($admin) {
            $admin_id = $admin['id'];
        } else {
            $this->error('系统错误，链接配置失败');
        }
        $order =  Db::table('fa_hf_order')->where('account', $account)->where('statuss', '2')->find();
        if ($order) {
            $this->error('由于运营商限制，请等待充值中的订单完成之后再提交');
        }

        $sxf = round($goods['price'] * 0.002, 2); //微信手续费
        $zzlr = 0;
        $price_arr = MyHelp::getPriceNew($admin, $goods['id']);

        $lr_arr = $price_arr['lr'];
        $price = $price_arr['price_h5'];
        $lirun = 0; //平台利润




        $data = [
            'admin_id' => $admin_id,
            'orderno' => $orderno,
            'account' => $account,
            'createtime' => time(),
            'update_time' => time(),
            'goodsid' => $goodsid,
            'code' => $goods['code'],
            'mz' => $goods['mz'],
            'user_id' => $u['id'],
            'province' => $Province,
            'city' => $City,
            'yys' => $yys,
            'cztype' => $goods['type'],
            'lirun' => $lirun,
            'price' => $price,
            'cbprice' => $goods['cb'],
            'sxf' => $sxf,
            'zzlr' => $zzlr,
            'lr_arr' => json_encode($lr_arr),
            'image' => $image,
            'title' => $goods['title'],
            'ordernoO' => $orderno,
            'api' => $goods['api']
        ];
        Db::table('fa_hf_order')->insert($data);


        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';


        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',
            'mch_id' => '1667355144', //李鹏飞
            // 'mch_id' => '1615197849',

            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        // $goods['price'] = 1;

        $result = $app->order->unify([
            'body' => '商品-' . $orderno,
            'out_trade_no' => $orderno,
            'total_fee' => $price * 100,
            //'spbill_create_ip' => '123.12.12.123', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => $u['openid_mp'],
        ]);

        //paySign = MD5(appId=wxd678efh567hg6787&nonceStr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id=wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key=qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6

        if ($result['return_code'] == 'SUCCESS') {
            if ($result['result_code'] == 'FAIL') {
                Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['err_code_des']]);
                return $this->error($result['err_code_des']);
            }
        } else {
            Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['return_msg']]);
            return $this->error($result['return_msg']);
        }
        // $payInfo =   (new \EasyWeChat\Payment\Jssdk\Client($app))->appConfig('prepay_id=' . $result['prepay_id']);

        $timeStamp = time();
        $qd = [
            'appId' => $config['app_id'],
            'nonceStr' => $result['nonce_str'],
            'package' => 'prepay_id=' . $result['prepay_id'],
            'signType' => 'MD5',
            'timeStamp' => $timeStamp,
            'key' => $config['key'],
        ];
        ///return http_build_query($qd);
        $paySign = strtoupper(md5(urldecode(http_build_query($qd))));
        $payInfo['appId'] = $config['app_id'];
        $payInfo['timeStamp'] = $timeStamp;
        $payInfo['nonceStr'] = $result['nonce_str'];
        $payInfo['package'] = 'prepay_id=' . $result['prepay_id'];
        $payInfo['signType'] = 'MD5';
        $payInfo['paySign'] = $paySign;

        return $this->success('提交成功', ['payInfo' => $payInfo, 'money' => $price]);
    }
    /**
     * 话费提交订单
     */
    public function hf_subOrder_hjy()
    {
        $account = $this->request->request('account');
        $goodsid = $this->request->request('goodsid');
        $token = $this->request->request('token'); //uniid
        // MyHelp::dingding('话费订单传参：' . json_encode($this->request->request()), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
        $key = $this->request->request('key'); //1小程序 2公众号h5
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $goods = Db::table('fa_hf_goods')->where('id', $goodsid)->find();
        if (!$goods) {
            $this->error('商品有误');
        }
        $account = str_replace(' ', '', $account);
        $mobileInfo = $this->getYys1($account);
        $mobileInfo_arr = json_decode($mobileInfo, true);
        if (!isset($mobileInfo_arr['result']['Province'])) {
            return $this->error('系统异常或手机号有误');
        }

        $Province = $mobileInfo_arr['result']['Province'];
        $City = $mobileInfo_arr['result']['City'];
        $Isp = $mobileInfo_arr['result']['Isp'];
        if ($Isp == '中国移动') {
            $yys = '1';
            $image = 'https://cdn.8nit.cn/uploads/20240101/eb0722ebcea3427f48c4dd8fada552a1.png';
        } elseif ($Isp == '中国联通') {
            $yys = '2';
            $image = 'https://cdn.8nit.cn/uploads/20240101/a09d4985e64f735f69f51dfe7e13d1be.png';
        } elseif ($Isp == '中国电信') {
            $yys = '3';
            $image = 'https://cdn.8nit.cn/uploads/20240101/fce2efbd9e7765b73cd9aed2cb6ea839.png';
        } else {
            $this->error('不支持的运营商');
        }

        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $orderno = 'HF' . date("Ymdhis")  . mt_rand(1000000, 99999999);
        $admin =  db::table('fa_admin')->where('key', $key)->find();
        if ($admin) {
            $admin_id = $admin['id'];
        } else {
            $this->error('系统错误，链接配置失败');
        }
        $order =  Db::table('fa_hf_order')->where('account', $account)->where('statuss', '2')->find();
        if ($order) {
            $this->error('由于运营商限制，请等待充值中的订单完成之后再提交');
        }

        $sxf = round($goods['price'] * 0.002, 2); //微信手续费
        $zzlr = 0;
        $price_arr = MyHelp::getPriceNew($admin, $goods['id']);

        $lr_arr = $price_arr['lr'];
        $price = $price_arr['price_h5'];
        $lirun = 0; //平台利润




        $data = [
            'admin_id' => $admin_id,
            'orderno' => $orderno,
            'account' => $account,
            'createtime' => time(),
            'update_time' => time(),
            'goodsid' => $goodsid,
            'code' => $goods['code'],
            'mz' => $goods['mz'],
            'user_id' => $u['id'],
            'province' => $Province,
            'city' => $City,
            'yys' => $yys,
            'cztype' => $goods['type'],
            'lirun' => $lirun,
            'price' => $price,
            'cbprice' => $goods['cb'],
            'sxf' => $sxf,
            'zzlr' => $zzlr,
            'lr_arr' => json_encode($lr_arr),
            'image' => $image,
            'title' => $goods['title'],
            'ordernoO' => $orderno,
            'api' => $goods['api']
        ];
        Db::table('fa_hf_order')->insert($data);
        return $this->success('提交成功', ['orderno' => $orderno, 'money' => $price]);
    }
    /**
     * 话费提交订单付款
     */
    public function hf_pay_hjy()
    {
        $orderno = $this->request->request('order');
        $openid = $this->request->request('openid');



        $order =  Db::table('fa_hf_order')->where('orderno', $orderno)->find();
        if (!$order) {
            return $this->error('订单不存在');
        }
        if ($order['statuss'] != '1') {
            return $this->error('该订单已付款');
        }
        $price = $order['price'];
        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';


        $config = [
            'app_id' => 'wxf070218e9dcfd347', // 公众号 APPID
            //'mch_id' => '1663340087',
            'mch_id' => '1615197849',
            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        // $goods['price'] = 1;

        $result = $app->order->unify([
            'body' => '商品-' . $orderno,
            'out_trade_no' => $orderno,
            'total_fee' => $price * 100,
            //'spbill_create_ip' => '123.12.12.123', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => $openid,
        ]);

        //paySign = MD5(appId=wxd678efh567hg6787&nonceStr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id=wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key=qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6

        if ($result['return_code'] == 'SUCCESS') {
            if ($result['result_code'] == 'FAIL') {
                Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['err_code_des']]);
                return $this->error($result['err_code_des']);
            }
        } else {
            Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['return_msg']]);
            return $this->error($result['return_msg']);
        }
        // $payInfo =   (new \EasyWeChat\Payment\Jssdk\Client($app))->appConfig('prepay_id=' . $result['prepay_id']);

        $timeStamp = time();
        $qd = [
            'appId' => $config['app_id'],
            'nonceStr' => $result['nonce_str'],
            'package' => 'prepay_id=' . $result['prepay_id'],
            'signType' => 'MD5',
            'timeStamp' => $timeStamp,
            'key' => $config['key'],
        ];
        ///return http_build_query($qd);
        $paySign = strtoupper(md5(urldecode(http_build_query($qd))));
        $payInfo['appId'] = $config['app_id'];
        $payInfo['timeStamp'] = $timeStamp;
        $payInfo['nonceStr'] = $result['nonce_str'];
        $payInfo['package'] = 'prepay_id=' . $result['prepay_id'];
        $payInfo['signType'] = 'MD5';
        $payInfo['paySign'] = $paySign;

        return $this->success('提交成功', ['payInfo' => $payInfo, 'money' => $price]);
    }
    public  function upgrade()
    {
        $token = $this->request->request('token'); //uniid
        $type = $this->request->request('type', 1); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        if ($type == 1) {
            $money = 10;
        } else {
            $money = 100;
        }
        $orderno = 'HHR' . date("Ymdhis")  . mt_rand(1000000, 99999999);
        $data = [
            'user_id' => $u['id'],
            'orderno' => $orderno,
            'createtime' => time(),
            'money' => $money,
            'type' => $type
        ];
        Db::table('fa_user_upgrade')->insert($data);


        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';


        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',
            'mch_id' => '1615197849',
            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hhr',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        // $goods['price'] = 1;

        $result = $app->order->unify([
            'body' => '商品-' . $orderno,
            'out_trade_no' => $orderno,
            'total_fee' => $money * 100,
            //'spbill_create_ip' => '123.12.12.123', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hhr', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => $u['openid_mp'],
        ]);

        //paySign = MD5(appId=wxd678efh567hg6787&nonceStr=5K8264ILTKCH16CQ2502SI8ZNMTM67VS&package=prepay_id=wx2017033010242291fcfe0db70013231072&signType=MD5&timeStamp=1490840662&key=qazwsxedcrfvtgbyhnujmikolp111111) = 22D9B4E54AB1950F51E0649E8810ACD6

        if ($result['return_code'] == 'SUCCESS') {
            if ($result['result_code'] == 'FAIL') {
                Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['err_code_des']]);
                return $this->error($result['err_code_des']);
            }
        } else {
            Db::table('fa_hf_order')->where('orderno', $orderno)->update(['remark' => $result['return_msg']]);
            return $this->error($result['return_msg']);
        }
        // $payInfo =   (new \EasyWeChat\Payment\Jssdk\Client($app))->appConfig('prepay_id=' . $result['prepay_id']);

        $timeStamp = time();
        $qd = [
            'appId' => $config['app_id'],
            'nonceStr' => $result['nonce_str'],
            'package' => 'prepay_id=' . $result['prepay_id'],
            'signType' => 'MD5',
            'timeStamp' => $timeStamp,
            'key' => $config['key'],
        ];
        ///return http_build_query($qd);
        $paySign = strtoupper(md5(urldecode(http_build_query($qd))));
        $payInfo['appId'] = $config['app_id'];
        $payInfo['timeStamp'] = $timeStamp;
        $payInfo['nonceStr'] = $result['nonce_str'];
        $payInfo['package'] = 'prepay_id=' . $result['prepay_id'];
        $payInfo['signType'] = 'MD5';
        $payInfo['paySign'] = $paySign;

        return $this->success('提交成功', ['payInfo' => $payInfo, 'money' => $money]);
    }
    /**
     * 获取微信js sdk
     */

    public function buildConfig()
    {
        //MyHelp::dingding('buildConfig订单传参：' . json_encode($this->request->request()), '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
        $url = $this->request->request('url');
        $signPackage = $this->getSignPackage($url, 'wx6a20a1300ba9e158', '59c34f438a350e30fc08c002276e752b');
        $config =  array(
            // 'debug' => true,
            'appId' => $signPackage['appId'],
            'timestamp' => $signPackage['timestamp'],
            'nonceStr' => $signPackage['nonceStr'],
            'signature' => $signPackage['signature'],
            // 'jsApiList' => array(
            //     'checkJsApi',
            //     'updateTimelineShareData',
            //     'hideOptionMenu',
            //     'updateAppMessageShareData',
            //     'hideMenuItems',
            //     'showMenuItems'
            // )
        );
        return $this->success('', $config);
    }
    public function getSignPackage($url, $appid, $screct)
    {
        $jsapiTicket = $this->getticket($appid, $screct);
        $timestamp = time();
        $nonceStr = $this->createNonceStr();
        $string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr&timestamp=$timestamp&url=$url";
        //  echo  $string;
        //  MyHelp::dingding($string, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');
        $signature = sha1($string);

        $signPackage = array(
            "appId"     => $appid,
            "nonceStr"  => $nonceStr,
            "timestamp" => $timestamp,
            "url"       => $url,
            "signature" => $signature,
            "rawString" => $string
        );
        return $signPackage;
    }
    public function getticket($appid, $screct)
    {
        // $appid = "wx98ebcf474e5e768b";
        // $screct = 'e8b343e5dea2822ff6dc7dee8a4ac9f2';
        //https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx98ebcf474e5e768b&secret=e8b343e5dea2822ff6dc7dee8a4ac9f2
        $rst =  http::post('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $screct);
        // return $rst;

        //{"access_token":"58_h6FceFakfdDpISY6ukmQZN2DIKq1i3951meIkIwK-BGE0_NZJ-9GuvFW2D6g9fVCkkI5GA9mcxWFlj8pZLP-KOAbNaOhfguPA950t2uTUs0","expires_in":7200,"refresh_token":"58_hqA39B0B7doacDnzJEgfhzIZTKqqc2AGVke__CMZffqLYVYtJgKBKnSjyWjJ0WS2i4HvUNTqvtT77cxcY3mzP5fhRnOIKFfu1VMxmnAcB4A","openid":"ozzUc5vtO3Y-c8j2SsVNfHKGLhiE","scope":"snsapi_base"}
        $rst_arr = json_decode($rst, true);
        // $openid = $rst_arr['openid'];
        $access_token = $rst_arr['access_token'];
        // return $access_token;
        $rst =  http::post('https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=' . $access_token . '&type=jsapi');
        $rst_arr = json_decode($rst, true);
        // $openid = $rst_arr['openid'];
        $access_token = $rst_arr['ticket'];
        return $access_token;
        //https: //api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi
    }
    private function createNonceStr($length = 16)
    {
        $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        $str = "";
        for ($i = 0; $i < $length; $i++) {
            $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
        }
        return $str;
    }
    /**
     * 提现
     */
    public  function txMoneySub()
    {
        $token = $this->request->request('token'); //uniid
        $money = $this->request->request('money'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $user = Db::table('fa_user')->where('unionid', $token)->find();
        if (cache::has('lqljj_' . $token)) {

            return $this->error(__('操作过于频繁,请10秒后重试'));
        }
        cache::set('lqljj_' . $token, '8888', 5);
        if (!$user) {
            $this->error('用户不存在');
        }
        if ($money <= 1) {
            $this->error('金额选择有误，最低提现1元');
        }
        if ($user['money'] < $money) {
            $this->error('余额不足，无法提现');
        }
        $newmoney = round($user['money'] - $money, 2);
        Db::table('fa_user')->where('id', $user['id'])->update(['money' => $newmoney]);
        $log = [
            'user_id' => $user['id'],
            'money' => $money * -1,
            'before' => $user['money'],
            'after' => $newmoney,
            'memo' => '余额提现',
            'createtime' => time()
        ];
        Db::table('fa_user_money_log')->insert($log);
        $order = 'TR' . date('YmdHis') . rand(1111111, 9999999);
        $pay = new pay();
        $rst =   $pay->toBalance($user['openid_xcx'], intval($money * 100), '余额提现', $order);
        //{"batch_id":"131000011083401975372722023122713330820322","batch_status":"ACCEPTED","create_time":"2023-12-27T20:38:40+08:00","out_batch_no":"sdfd111111111"}
        $rst_arr = json_decode($rst, true);
        ////{"code":"PARAM_ERROR","detail":{"location":"body","value":""},"message":"无法将 JSON 输入源“/body/total_amount”映射到目标字段“转账总金额”中，此字段需要一个合法的 64 位有符号整数"}
        MyHelp::dingding('话费订单提现：' . $rst, '3acdcd1692e6ca3fee6bf21ba73c6a837e1ff69b95d63a4be3c7bd3df25886b6');

        if (isset($rst_arr['code'])) {

            $newmoney = $user['money'];
            Db::table('fa_user')->where('id', $user['id'])->update(['money' => $newmoney]);
            $log = [
                'user_id' => $user['id'],
                'money' => $money,
                'before' => round($user['money'] - $money, 2),
                'after' => $newmoney,
                'memo' => '提现失败退回',
                'createtime' => time()
            ];
            Db::table('fa_user_money_log')->insert($log);
            return $this->error($rst_arr['message']);
        } else {
            $new = [
                'admin_id' => $user['admin_id'],
                'user_id' => $user['id'],
                'money' => $money,
                'money2' => $money,
                'msg' => '系统打款中',
                'openid' => $user['openid_xcx'],
                'type' => '2',
                'addtime' => time(),
                'zztype' => 1,
                'orderno' => $rst_arr['batch_id'],
                'order' => $order
            ];
            Db::table('fa_tixian')->insert($new);
            //{"batch_id":"131000111018901975372722023122887152331213","batch_status":"ACCEPTED","create_time":"2023-12-28T20:33:52+08:00","out_batch_no":"TR202312282033529579186"}

            return $this->success('提交成功');
        }
    }
    /**
     * 提现列表
     */
    public  function txlist()
    {
        $token = $this->request->request('token'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        $user = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$user) {
            $this->error('用户不存在');
        }
        $order = Db::table('fa_tixian')->order('id desc')->where('user_id', $user['id'])->limit(100)->select();
        return $this->success('', $order);
    }
    /**
     * 提现状态查询
     */
    public  function tiquery()
    {
        $order = Db::table('fa_tixian')->where('statuss', '0')->limit(10)->select();
        foreach ($order as $key => $value) {
            $pay = new pay();
            $rst =   $pay->query($value['order']);
            $rst_arr = json_decode($rst, true);
            if ($rst_arr['transfer_batch']['batch_status'] == 'FINISHED') {
                Db::table('fa_tixian')->where('id', $value['id'])->update(['statuss' => '1', 'updatetime' => time(), 'msg' => '受理成功']);
            } elseif ($rst_arr['transfer_batch']['batch_status'] == 'FAIL') {
                Db::table('fa_tixian')->where('id', $value['id'])->update(['statuss' => '2', 'updatetime' => time(), 'msg' => isset($rst_arr['transfer_batch']['close_reason']) ? $rst_arr['transfer_batch']['close_reason'] : '受理失败']);
            }
        }
        return 'ok';
    }

    /**
     * 充值余额提交
     */
    public function czMoneySub()
    {
        $token = $this->request->request('token'); //uniid
        $money = $this->request->request('money'); //uniid
        if (!$token) {
            $this->error('token参数错误');
        }
        if ($money < 5) {
            $this->error('余额最低充值5元');
        }
        if ($money <= 0) {
            $this->error('金额选择有误');
        }
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $apiclient_cert = __DIR__ . '/cert/apiclient_cert_gzs.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key_gzs.pem';
        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',
            'mch_id' => '1615197849',
            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/yue',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        $orderno_new = 'YUE' . date("Ymdhis")  . mt_rand(1000000, 99999999);
        $data = [
            'user_id' => $u['id'],
            'orderno' => $orderno_new,
            'createtime' => time(),
            'money' => $money
        ];
        Db::table('fa_user_money_cz')->insert($data);
        $result = $app->order->unify([
            'body' => '商品-' . $orderno_new,
            'out_trade_no' => $orderno_new,
            'total_fee' => $money * 100,
            //'spbill_create_ip' => '123.12.12.123', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/yue', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => $u['openid_mp'],
        ]);
        if ($result['return_code'] == 'SUCCESS') {
            if ($result['result_code'] == 'FAIL') {

                return $this->error($result['err_code_des']);
            }
        } else {

            return $this->error($result['return_msg']);
        }

        $timeStamp = time();
        $qd = [
            'appId' => $config['app_id'],
            'nonceStr' => $result['nonce_str'],
            'package' => 'prepay_id=' . $result['prepay_id'],
            'signType' => 'MD5',
            'timeStamp' => $timeStamp,
            'key' => $config['key'],
        ];
        ///return http_build_query($qd);
        $paySign = strtoupper(md5(urldecode(http_build_query($qd))));
        $payInfo['appId'] = $config['app_id'];
        $payInfo['timeStamp'] = $timeStamp;
        $payInfo['nonceStr'] = $result['nonce_str'];
        $payInfo['package'] = 'prepay_id=' . $result['prepay_id'];
        $payInfo['signType'] = 'MD5';
        $payInfo['paySign'] = $paySign;
        return $this->success('提交成功', ['payInfo' => $payInfo, 'money' => $money]);
        return $this->success('', $data);
    }
    /**
     * 话费提交订单 未付款
     */
    public function hf_subOrderWfk()
    {

        $order_id = $this->request->request('order_id');
        $token = $this->request->request('token'); //uniid
        //  $token = $this->request->request('token');
        if (!$token) {
            $this->error('token参数错误');
        }
        $order = Db::table('fa_hf_order')->where('id', $order_id)->find();
        if (!$order) {
            $this->error('订单不存在');
        }
        if ($order['statuss'] != '1') {
            $this->error('订单已付款或状态异常');
        }
        if (time() - $order['createtime'] > 600) {
            Db::table('fa_hf_order')->where('id', $order_id)->delete();
            $this->error('订单已超时，请重新下单');
        }
        $apiclient_cert = __DIR__ . '/cert/apiclient_cert.pem';
        $apiclient_key = __DIR__ . '/cert/apiclient_key.pem';
        $u = Db::table('fa_user')->where('unionid', $token)->find();
        if (!$u) {
            $this->error('用户不存在');
        }
        $config = [
            'app_id' => 'wx6a20a1300ba9e158', // 公众号 APPID
            //'mch_id' => '1663340087',
            'mch_id' => '1615197849',
            'key' => 'f1d56asv15as4df594sa56v1sa894v89',
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf',
            'cert_path' => $apiclient_cert, // optional, 退款，红包等情况时需要用到
            'key_path' => $apiclient_key, // optional, 退款，红包等情况时需要用到
            // 'mode' => 'dev',
        ];
        $app = Factory::payment($config);
        $orderno_new = 'HF' . date("Ymdhis")  . mt_rand(1000000, 99999999);

        $result = $app->order->unify([
            'body' => '商品-' . $orderno_new,
            'out_trade_no' => $orderno_new,
            'total_fee' => $order['price'] * 100,
            //'spbill_create_ip' => '123.12.12.123', // 可选，如不传该参数，SDK 将会自动获取相应 IP 地址
            'notify_url' => 'https://mch.8nit.cn/api/babaohui/payCallback/pro/hf', // 支付结果通知网址，如果不设置则会使用配置里的默认地址
            'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
            'openid' => $u['openid_mp'],
        ]);
        if ($result['return_code'] == 'SUCCESS') {
            if ($result['result_code'] == 'FAIL') {
                Db::table('fa_hf_order')->where('id', $order['id'])->update(['remark' => $result['err_code_des']]);
                return $this->error($result['err_code_des']);
            }
        } else {
            Db::table('fa_hf_order')->where('id', $order['id'])->update(['remark' => $result['return_msg']]);
            return $this->error($result['return_msg']);
        }
        Db::table('fa_hf_order')->where('id', $order['id'])->update(['orderno' => $orderno_new, 'ordernoO' => $orderno_new]);
        $timeStamp = time();
        $qd = [
            'appId' => $config['app_id'],
            'nonceStr' => $result['nonce_str'],
            'package' => 'prepay_id=' . $result['prepay_id'],
            'signType' => 'MD5',
            'timeStamp' => $timeStamp,
            'key' => $config['key'],
        ];
        ///return http_build_query($qd);
        $paySign = strtoupper(md5(urldecode(http_build_query($qd))));
        $payInfo['appId'] = $config['app_id'];
        $payInfo['timeStamp'] = $timeStamp;
        $payInfo['nonceStr'] = $result['nonce_str'];
        $payInfo['package'] = 'prepay_id=' . $result['prepay_id'];
        $payInfo['signType'] = 'MD5';
        $payInfo['paySign'] = $paySign;
        return $this->success('提交成功', ['payInfo' => $payInfo, 'money' => $order['price']]);
    }
    /**
     * 常见问题处理方式
     */
    public function getHandbookList()
    {
        $a = '[{"id":"1532714873069375488","createTime":"2022-06-03 21:24:37","content":"<p>1.计价逻辑：采用首续重计价方式；<br>2.计费重量：取体积重量与实际重量两者的较大值；[申通快递]体积重量=长(cm) x 宽(cm) x 高(cm) ÷8000<br>3.计费重量进位规则：重量不足1kg的，按1kg计算；<br>4.申通快递不保价不予理赔，具体政策可咨询揽件快递员，易碎、贵重、生鲜、耗材、包装等会有额外政策价格请现成与快递员核实清楚。<br>5.限重50公斤，超过50公斤以上按照20元1公斤续重10元每公斤计费。<br>6.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"申通快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532714935149268992","createTime":"2022-06-03 21:24:52","content":"<p> </p><p>1，圆通快递，全国上门取件，部分区域最快2小时上门，当天预约订单当天上门揽收，原则上一天一收。<br> &nbsp; 取件范围：支持全国地区（不含港澳台），覆盖31个省份互寄互发，961条省级线路，14万条市级线路。<br>2，原则上当天16:00前下单，当天上门取件；当天16:00之后下单，次日上门取件。<br>3，当天揽件率&gt;=95%，及时接单率&gt;=98%<br>4，计泡比：8000，即体积重量(KG)=长（cm）*宽（cm）*高（cm）/8000，续重不足1KG按1KG计算，<br> &nbsp; 结算重量取实际重量与体积重量中的大值，体积重量及实际重量均以中心称重测量值为准。<br>5，未保价产品及易碎类、易泄漏类产品不予理赔。<br>6，限重50KG，最长边不超1.5米，三边总和不超2.4米。超过50KG，快递员拒绝揽收。。<br>7，以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p><p><br></p><p><br></p>","title":"圆通快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532714987670343680","createTime":"2022-06-03 21:25:04","content":"<p>1.计价逻辑：采用首续重计价方式；<br>2.计费重量：取体积重量与实际重量两者的较大值；[极兔快递]体积重量=长(cm) x 宽(cm) x 高(cm) ÷8000<br>3.计费重量进位规则：重量不足1kg的，按1kg计算；<br>4.极兔快递不保价不予理赔。<br>5.限重50kg。<br>6.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"极兔快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1545677222533271552","createTime":"2022-07-09 15:52:22","content":"<p>1.计价逻辑：按计费重量计费，其中：轻泡货按照6000系数折算计费重量（计费重量=长×宽×高/6000，cm3），最低一票：38元起；<br>2.计费重量：取体积重量与实际重量两者的较大值；体积重量=长(cm) x 宽(cm) x 高(cm) ÷ 抛重；<br>3.计费重量进位规则：重量不足1kg的，按1kg计算； &nbsp; &nbsp; &nbsp; <br>4.顺心捷达渠道不保价不予理赔，保价费率千分之二；<br> &nbsp;易碎品包装不符合运输规范破损不予理赔；<br> &nbsp;禁止发送生鲜，后果自负；<br> &nbsp;耗材、包装等会有额外政策价格，超长、超重、外发、退回等情形均会造成费用的增加，请与快递员核实清楚。<br>5.注意：下单后更换收件地址或中途更换收件地址，会以原价计费。<br>6.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"顺心捷达规则说明","type":1,"creator":"820682523800637440"},{"id":"1537648021964197889","createTime":"2022-06-17 12:07:11","content":"<p style=\"text-align: start;\"> 当您点击本协议“ 同意 ” 按钮前，应当认真阅读本协议，请您务必审慎阅读、充分理解各条款内容，特别是免除或者限制责任的条款、法律适用和争议解决条款。<strong>免除或者限制责任的条款将以粗体或下划线标识，您应重点阅读。</strong>阅读本协议的过程中，如果您不同意本协议条款，请立即停止使用服务。如您对协议有任何疑问，可向客服咨询。</p><p style=\"text-align: start;\">欢迎用户（以下称“ 您 ” ）与河南八恩科技有限公司（以下称“八恩科技”）共同签署《寄件服务协议》（以下称 “ 本协议 ” ）并使用八宝汇电商物流管理系统（以下称“八宝汇系统”）下单。</p><p style=\"text-align: start;\">【签约动作】</p><p style=\"text-align: start;\">当您进入八宝汇电商物流管理系统下单寄件，寄件信息填写完毕后、勾选“ 我已阅读并同意服务协议 ” 、点击 “ 立即下单 ”或其他相似操作 ，即表示您已充分阅读、理解并接受本协议的全部内容。</p><p style=\"text-align: start;\">【提示条款】</p><p style=\"text-align: start;\">各服务条款前所列索引关键词仅为帮助您理解该条款表达的主旨之用，不影响或限制本协议条款的含义或解释。为维护您自身权益，建议您仔细阅读各条款具体表述。</p><p style=\"text-align: start;\"><strong>一、定义</strong></p><p style=\"text-align: start;\">1.寄件服务：您在八宝汇电商物流管理系统下单后，系统根据您的实际情况向您同步相关寄件快递信息，并向您展示快递员联系方式。</p><p style=\"text-align: start;\">2.八宝汇系统：通过软件技术手段与快递公司快递下单配送系统对接，功能包含但不限于快递下单、运单管理、物流轨迹查询等，平台入口以八宝汇系统提供的服务页面为准。</p><p style=\"text-align: start;\">二、<strong>八宝汇电商物流管理系统为您提供的服务</strong></p><p style=\"text-align: start;\">1<strong>.</strong>八宝汇电商物流管理系统为您提供技术服务。您可以使用八宝汇系统填写寄件订单信息、预约上门取件时间、对寄递物品在线保价、在线支付运费、发布订单信息、快递公司承接并揽收您发布的订单信息。</p><p style=\"text-align: start;\">2.您同意，八宝汇系统是技术服务提供方，包裹揽收及配送由快递公司完成，发件方需遵守快递公司的运输配送准则及相关约定。</p><p style=\"text-align: start;\">3.您同意，八宝汇是技术服务提供方，八宝汇系统不保证在您预约的上门时间内快递员一定会承接并处理您的寄件订单。 八宝汇系统也不对快递公司的服务履约和服务质量承担任何保证和担保责任。</p><p style=\"text-align: start;\">三、<strong>您使用上门取件服务应遵守的交易规则：</strong></p><p style=\"text-align: start;\">1.您使用八宝汇系统下单时，应仔细填写寄件信息（包括寄件人、寄件人联系方式、寄件地址、收件人、收件人联系方式、收件人联系地址、预约上门取件时间、物品类型、保价等信息），并保证上述您填写信息的准确性、有效性、完整性。 如因您填写的寄件信息不准确、无效或不完整，导致您下达的订单无法顺利履行（包括无法按时揽收、揽收后无法派送等），您应自行承担全部责任。</p><p style=\"text-align: start;\">2.您在寄递物品前，应妥善整理您需要寄递的物品，并按照快递公司的要求进行打包，同时准备好您在下单页面填写的寄件人的有效身份证件，配合服务人员依法验视订单对应的寄递物品和寄件人身份证件。</p><p style=\"text-align: start;\"><strong>3.您将寄递物品交付快递员之前，应当按照快递公司的要求核验相关信息，避免不必要的损失。 如核验不一致的，您有权拒绝向快递员交付寄递物品，否则由此造成的损失由您本人承担。</strong></p><p style=\"text-align: start;\"><strong>4.您应遵守国家相关法律法规规定，不得寄递毒品、易燃易爆品等一切国家法律法规禁止寄递的物品，否则快递员有权拒绝履行您的订单，并有权将您违规禁寄物品的情况依法报告给主管机关，由此导致的后果、责任（包括但不限于行政责任、刑事责任等）均由您本人承担。除国家禁止寄递的物品外，快递员有权根据自身的专业能力判断是否承运依照法律法规规定限制寄递的物品，具体以快递员验视后确认是否揽收为准。</strong></p><p style=\"text-align: start;\"><strong>四、费用计算及支付方式</strong></p><p style=\"text-align: start;\">1.费用计算标准</p><p style=\"text-align: start;\">八宝汇系统为您提供相应快递服务，具体价格标准、费率、折扣等以八宝汇系统实时公布为准。</p><p style=\"text-align: start;\">单笔订单的最终费用以各快递公司提供的订单数据（包括但不限于重量、体积、耗材等）为准。</p><p style=\"text-align: start;\">2.费用结算方式</p><p style=\"text-align: start;\">（1）账号充值</p><p style=\"text-align: start;\">用户账号注册成功后，需要在对应账户中充值方可使用。您知晓，当您的账户余额低于警戒金额（以系统显示为准）账号将无法正常使用，请您不时查看账号内系统提示，以防账户余额不足影响您的账号正常使用。</p><p style=\"text-align: start;\">为了保障您对系统的使用，您的账号对应账户的充值方式为：向八恩科技指定账户对公打款或通过八宝汇系统直接线上充值。线上充值所产生的第三方系统交易费用由您个人承担。</p><p style=\"text-align: start;\">（2）结算方式</p><p style=\"text-align: start;\">八宝汇系统对用户采取实时扣款方式结算。即对您的账户或通过您账户发生的业务，单笔发生单笔扣款。系统将在订单发生时对您的账户款项进行等额预冻结，待该笔订单完成后，以实际发生费用进行扣款。</p><p style=\"text-align: start;\">具体费用和价格明细以八宝汇系统实时数据为准，以用户在八宝汇系统下单时对应的系统价格计算。</p><p style=\"text-align: start;\">3.余额提现</p><p style=\"text-align: start;\">您对于用户账号在系统内的余额，可进行提现操作。八宝汇系统为所有用户提供余额提现服务。用户应当按照系统规则申请余额提现，申请通过后相关款项将根据系统规则支付至用户相关账户。</p><p style=\"text-align: start;\">4.争议费用处理</p><p style=\"text-align: start;\">（1）对于因信息同步不及时等原因导致的物流订单实际重量与八宝汇系统记录重量不符导致订单物流费用差异或因其他原因导致订单物流费用产生差异的，以八宝汇系统结算数据为准。实际费用超出系统记录费用的，八宝汇系统将按照实际费用将差额从用户账号余额扣除，实际费用低于系统记录费用的，八宝汇系统将按照实际费用将差额支付给您的八宝汇系统账户（当您账户余额不足时或您有陈欠费用时，八恩科技有权将该差额进行扣除以抵扣前述不足款项、陈欠费用）。扣除、支付差额费用周期以八宝汇系统与其合作快递公司结算周期为准。</p><p style=\"text-align: start;\">（2）逆向业务服务费用</p><p style=\"text-align: start;\">逆向业务指因拒收、退换货产生的二次运输服务。因逆向业务产生的费用，由您自行承担，结算周期、结算费用以八宝汇系统与其合作快递公司结算周期和费用为准，八宝汇系统将按照周期将相关费用从用户账号中进行划转扣除。</p><p style=\"text-align: start;\"><strong>（3）如用户恶意利用八宝汇系统或快递公司系统漏洞进行操作给八恩科技造成损失的，八宝汇系统有权从用户账号扣除相应款项作为损失赔偿，账户款项不足以弥补八恩科技损失的，八恩科技可向用户继续追偿。同时，八恩科技保留利用法律手段向用户追究责任的权利，届时除损失本金，用户还将承担扩大的经济责任（包括但不限于违约金、赔偿金、利息、诉讼费、保全费、公证费、律师费、差旅费及其他八恩科技因维权产生的合理支出）。</strong></p><p style=\"text-align: start;\">5.发票开具</p><p style=\"text-align: start;\">您可以通过系统申请方式向八宝汇系统申请发票。具体申请流程、发票提供方式等以八宝汇系统内容为准。</p><p style=\"text-align: start;\"><strong>五、货物的毁损、灭失赔偿</strong></p><p style=\"text-align: start;\">八宝汇系统建议您对您的贵重寄递物品购买保价服务，以降低未保价给您带来的损失及风险。保价费率以系统数据为准。</p><p style=\"text-align: start;\">保价与赔偿：根据您配送货物的实际价值和赔偿要求，自行评估并选择保价服务。保价业务的选择与否对于配送货物毁损、灭失之后的赔付标准具有非常重要的意义，特约定赔付标准如下：</p><p style=\"text-align: start;\">货物在快递公司投递（配送）过程中：</p><p style=\"text-align: start;\">（1）已保价的货物，由快递公司原因造成货物丢失或部分/全部损毁、灭失（包装材料破损除外）的，以快递公司保价规则、政策为准。</p><p style=\"text-align: start;\">（2）未保价的货物，由于快递公司原因造成货物丢失或部分/全部毁损、灭失（包装材料破损除外）的，按照快递公司赔付政策、标准执行，八宝汇系统可提供必要的协助和配合。</p><p style=\"text-align: start;\"><strong>六、八宝汇电商物流管理系统的责任承担和免除</strong></p><p style=\"text-align: start;\"><strong>您了解并同意，八宝汇系统不对因下述情况而导致的任何损害赔偿承担责任，包括但不限于利润、名誉、商誉、使用、数据等方面的损失或其它无形损失的损害赔偿：</strong></p><p style=\"text-align: start;\"><strong>（1）使用或未能使用服务平台的服务；</strong></p><p style=\"text-align: start;\"><strong>（2）第三方未经批准地使用用户的账户或更改用户的数据；</strong></p><p style=\"text-align: start;\"><strong>（3） 通过平台的服务购买或获取任何商品、样品、数据、信息等行为或替代行为产生的费用及损失；</strong></p><p style=\"text-align: start;\"><strong>（4）用户对服务平台的服务的误解；</strong></p><p style=\"text-align: start;\"><strong>（5）任何非因八宝汇电商物流管理系统的原因而引起的与服务平台的服务有关的其它损失。</strong></p><p style=\"text-align: start;\"><strong>七、用户信息和隐私条款</strong></p><p style=\"text-align: start;\"><strong>1.用户应当保证其上传的所有信息（包括相关寄件人姓名、寄件人电话、收寄地址及收寄物品信息等相关信息）真实有效，且用户对于该等信息的上传行为合法、合规，由此产生的任何争议、纠纷均由用户自行解决，八宝汇系统不承担相应责任。</strong></p><p style=\"text-align: start;\">2.八宝汇电商物流管理系统会严格保护您上传的用户及相关信息（包括姓名、地址、联系方式、身份信息等隐私信息），除非得到信息所有者的授权或法律法规、本条款另有规定外，八宝汇系统不会公开透露任何用户隐私信息。</p><p style=\"text-align: start;\"><strong>八、其他约定</strong></p><p style=\"text-align: start;\">1.本协议适用中华人民共和国大陆地区法律。</p><p style=\"text-align: start;\">2.本协议内容包括本协议正文及所有八宝汇系统已经发布的或将来可能发布的各类规则，所有规则为本协议不可分割的组成部分，与协议正文具有同等法律效力。八宝汇电商物流管理系统有权根据国家法律法规的更新、产品和服务规则的调整需要不时地制订、修改本协议或各类规则，并以八宝汇电商物流管理系统APP 、小程序或官方网站公示的方式进行告知。如您继续使用八宝汇系统提供的服务的，即表示您接受修订的协议和规则。</p><p style=\"text-align: start;\">3.本条款的订立、执行和解释及争议的解决均应适用中华人民共和国大陆地区法律。如双方就本条款内容或其执行发生任何争议，双方应尽力友好协商解决；协商不成，任何一方可向本协议签订地辽宁省沈阳市铁西区人民法院提起诉讼。</p><p style=\"text-align: start;\">4.若本协议条款中的某条款被法院或政府机构认定为无效或部分无效，则您同意除无效条款外仍应执行本协议其他有效条款。</p><p style=\"text-align: start;\"><strong>附录：</strong></p><p style=\"text-align: start;\">您的托寄物品应遵守国家相关规定，不属于禁止生产、销售、传播的物品，不属于禁止或限制寄递的违禁品、假冒伪劣产品；托寄物不会造成收件人或其他第三方人身或财产的损害。</p><p style=\"text-align: start;\">（一）禁止寄递物品目录：应国家邮政局、公安部、国家安全部三方部门联合发布的《禁止寄递物品管理规定》要求，以下物品的寄递会因禁止寄递而被拒收。</p><p style=\"text-align: start;\">一、枪支（含仿制品、主要零部件）弹药</p><p style=\"text-align: start;\">1 ．枪支（含仿制品、主要零部件）：如手枪、步枪、冲锋枪、防暴枪、气枪、猎枪、运动枪、麻醉注射枪、钢珠枪、催泪枪等。</p><p style=\"text-align: start;\">2 ．弹药（含仿制品）：如子弹、炸弹、手榴弹、火箭弹、照明弹、燃烧弹、烟幕（雾）弹、信号弹、催泪弹、毒气弹、地雷、手雷、炮弹、火药等。</p><p style=\"text-align: start;\">二、管制器具</p><p style=\"text-align: start;\">1 ．管制刀具：如匕首、三棱刮刀、带有自锁装置的弹簧刀（跳刀）、其他相类似的单刃、双刃、三棱尖刀等。</p><p style=\"text-align: start;\">2 ．其他：如弩、催泪器、催泪枪、电击器等。</p><p style=\"text-align: start;\">三、爆炸物品</p><p style=\"text-align: start;\">1 ．爆破器材：如炸药、雷管、导火索、导爆索、爆破剂等。</p><p style=\"text-align: start;\">2 ．烟花爆竹：如烟花、鞭炮、摔炮、拉炮、砸炮、彩药弹等烟花爆竹及黑火药、烟火药、发令纸、引火线等。</p><p style=\"text-align: start;\">3 ．其他：如推进剂、发射药、硝化棉、电点火头等。</p><p style=\"text-align: start;\">四、压缩和液化气体及其容器</p><p style=\"text-align: start;\">1 ．易燃气体：如氢气、甲烷、乙烷、丁烷、天然气、液化石油气、乙烯、丙烯、乙炔、打火机等。</p><p style=\"text-align: start;\">2 ．有毒气体：如一氧化碳、一氧化氮、氯气等。</p><p style=\"text-align: start;\">3 ．易爆或者窒息、助燃气体：如压缩氧气、氮气、氦气、氖气、气雾剂等。</p><p style=\"text-align: start;\">五、易燃液体如汽油、柴油、煤油、桐油、丙酮、乙醚、油漆、生漆、苯、酒精、松香油等。</p><p style=\"text-align: start;\">六、易燃固体、自燃物质、遇水易燃物质</p><p style=\"text-align: start;\">1 ．易燃固体：如红磷、硫磺、铝粉、闪光粉、固体酒精、火柴、活性炭等。</p><p style=\"text-align: start;\">2 ．自燃物质：如黄磷、白磷、硝化纤维（含胶片）、钛粉等。</p><p style=\"text-align: start;\">3 ．遇水易燃物质：如金属钠、钾、锂、锌粉、镁粉、碳化钙（电石）、氰化钠、氰化钾等。</p><p style=\"text-align: start;\">七、氧化剂和过氧化物如高锰酸盐、高氯酸盐、氧化氢、过氧化钠、过氧化钾、过氧化铅、氯酸盐、溴酸盐、硝酸盐、双氧水等。</p><p style=\"text-align: start;\">八、毒性物质如砷、砒霜、汞化物、铊化物、氰化物、硒粉、苯酚、汞、剧毒农药等。</p><p style=\"text-align: start;\">九、生化制品、传染性、感染性物质如病菌、炭疽、寄生虫、排泄物、医疗废弃物、尸骨、动物器官、肢体、未经硝制的兽皮、未经药制的兽骨等。</p><p style=\"text-align: start;\">十、放射性物质如铀、钴、镭、钚等。</p><p style=\"text-align: start;\">十一、腐蚀性物质如硫酸、硝酸、盐酸、蓄电池、氢氧化钠、氢氧化钾等。</p><p style=\"text-align: start;\">十二、毒品及吸毒工具、非正当用途麻醉药品和精神药品、非正当用途的易制毒化学品</p><p style=\"text-align: start;\">1 ．毒品、麻醉药品和精神药品：如鸦片（包括罂粟壳、花、苞、叶）、吗啡、海洛因、可卡因、大麻、甲基苯丙胺（冰毒）、氯胺酮、甲卡西酮、苯丙胺、安钠咖等。</p><p style=\"text-align: start;\">2 ．易制毒化学品：如胡椒醛、黄樟素、黄樟油、麻黄素、伪麻黄素、羟亚胺、邻酮、苯乙酸、溴代苯丙酮、醋酸酐、甲苯、丙酮等。</p><p style=\"text-align: start;\">3 ．吸毒工具：如冰壶等。</p><p style=\"text-align: start;\">十三、非法出版物、印刷品、音像制品等宣传品如含有反动、煽动民族仇恨、破坏国家统一、破坏社会稳定、宣扬邪教、宗教极端思想、淫秽等内容的图书、刊物、图片、照片、音像制品等。</p><p style=\"text-align: start;\">十四、间谍专用器材如暗藏式窃听器材、窃照器材、突发式收发报机、一次性密码本、密写工具、用于获取情报的电子监听和截收器材等。</p><p style=\"text-align: start;\">十五、非法伪造物品如伪造或者变造的货币、证件、公章等。</p><p style=\"text-align: start;\">十六、侵犯知识产权和假冒伪劣物品</p><p style=\"text-align: start;\">1 ．侵犯知识产权：如侵犯专利权、商标权、著作权的图书、音像制品等。</p><p style=\"text-align: start;\">2 ．假冒伪劣：如假冒伪劣的食品、药品、儿童用品、电子产品、化妆品、纺织品等。</p><p style=\"text-align: start;\">十七、濒危野生动物及其制品如象牙、虎骨、犀牛角及其制品等。</p><p style=\"text-align: start;\">十八、禁止进出境物品如有碍人畜健康的、来自疫区的以及其他能传播疾病的食品、药品或者其他物品；内容涉及国家秘密的文件、资料及其他物品。</p><p style=\"text-align: start;\">十九、其他物品《危险化学品目录》《民用爆炸物品品名表》《易制爆危险化学品名录》《易制毒化学品的分类和品种目录》《中华人民共和国禁止进出境物品表》载明的物品和《人间传染的病原微生物名录》载明的第一、二类病原微生物等，以及法律、行政法规、国务院和国务院有关部门规定禁止寄递的其他物品。</p><p style=\"text-align: start;\">限制寄递物品目录应国家邮政局等三方部门联合发布的《禁止寄递物品管理规定》要求，以下物品的寄递会有限制。一、活物不能邮递。二、手机不能空运、只能陆运。三、白酒不能超过 56 度，酒精不能邮递。四、每人的单份邮递品，邮递香烟不能超过两条物不能邮递。</p><p style=\"text-align: start;\">不支持生鲜等保质期短的物品寄递，由此产生的任何问题，由寄方自行承担。</p>","title":"八宝汇系统寄件服务协议","type":1,"creator":"820682523800637440"},{"id":"1532715185272393728","createTime":"2022-06-03 21:25:51","content":"<p>1.预约与取件时间：可预约早8点-晚8点范围内时间取件。与取件快递员联系时请务必注意取件时间，夜间取件（晚8点-早8点）会额外增加50-100元取货费用<br/>2.抛重：陆运件5000，其他服务方式均为6000<br/>3.系统默认无回单，产生回单会增加7元/票额外增值费用<br/>4.货物送达后请收件方及时取件，否则会产生额外保管费用<br/>5.每票最低保价2000<br/>6.超长费：任意一边超长1.2米以上会产生超长费用<br/>7.超重费：单件大于1000公斤会产生每件100元超重费；单件大于2000公斤会产生每件200元超重费<br/>8.木架钢架会产生额外增值费，依物品体积立方术和件数为基础计费<br/>9.送货爬楼、取货爬楼会产生增值费用，依据楼层增加每票费用<br/>10.其它封箱/拉膜、贴标签、上架、超区、拆木架、开箱换箱、清货、多次派送等均会产生相应增值费用<br/>11.注意：快递员揽收时取消或者货物退回也收取50取件费<br/>12.货物需包装完好，裸货不取</p>","title":"跨越重货规则说明","type":1,"creator":"820682523800637440"},{"id":"1532715135276290048","createTime":"2022-06-03 21:25:39","content":"<p>1，韵达快递计价逻辑：采用首续重计价方式计费。结算重量取实际重量与体积重量中的大值，体积重量及实际重量均以中心称重测量值为准。<br>2，计抛比：12000，即体积重量(KG)=长(CM)*宽(CM)*高(CM)/8000，续重不足1KG按1KG计算。<br>3．重量规定：单件物品在50公斤-100公斤内的快件，各中转站收取0.2元/公斤的单件大货费（含所有网点），单件不能超过100公斤以上。<br>4．长度规定：单件物品最长不得超过2米、三边之和不得超过3米。<br>5．体积规定：单件物品体积不得超过0.8立方。<br>6. &nbsp;保价理赔规定：保价费用按照保价金额的4.5‰，不保价不能理赔。<br>7，以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"韵达快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532715092024627200","createTime":"2022-06-03 21:25:29","content":"<p>1，中通快递，现阶段只限中通覆盖区域，超区件中通转EMS等快递，按实际价格结算。<br>2，计抛比：8000，即体积重量(KG)=长（cm）*宽（cm）*高（cm）/8000，续重不足1KG按1KG计算，<br> &nbsp; 结算重量取实际重量与体积重量中的大值，体积重量及实际重量均以中心称重测量值为准。<br>3，未保价产品及易碎类、易泄漏类产品不予理赔。<br>4，单件重量50KG以上，单边长度超1.6M，单边高度和宽度同时超0.9M，三边之和超3M，快递员拒绝揽收。。<br>5，以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。<br>6，拦截退回会增加逆向费，破损件须在15日内剔除理赔</p>","title":"中通快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532715032700391424","createTime":"2022-06-03 21:25:15","content":"<p>顺丰渠道因疫情原因导致的订单退回八宝汇会为您整单退费(包含寄出与退回)，请您在异常订单里提交，原因选择“疫情退回”。<br>1.计价逻辑：采用首续重计价方式；<br>2.计费重量：取体积重量与实际重量两者的较大值；[顺丰速运]体积重量=长(cm) x 宽(cm) x 高(cm) ÷ 抛重<br>（大部分线路抛重更改为12000，个别线路6000-12000）<br>3.计费重量进位规则：重量不足1kg的，按1kg计算； &nbsp; &nbsp; &nbsp; <br>4.顺丰速运不保价不予理赔，具体政策可咨询揽件快递员；<br> &nbsp;易碎、贵重、生鲜、耗材、包装等会有额外政策价格，超长、超重、外发、退回等情形均会造成费用的增加，请与快递员核实清楚。<br>5.限重300公斤。<br>6.注意：下单后更换收件地址或中途更换收件地址，会以原价计费。<br>7.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"顺丰快递规则说明","type":1,"creator":"820682523800637440"}]';
        $b = '[{"id":"1721099955764072448","createTime":"2023-11-05 17:39:41","content":"<p><strong>运单未揽收可直接在运单查询界面取消运单，运费会原路退回。</strong></p><p><br></p>","title":"取消订单及退款问题","type":1,"creator":"yundiadmin"},{"id":"1721098950544592896","createTime":"2023-11-05 17:35:41","content":"<p><strong>辛苦您向在线客服提供下运单号，客服反馈催促取件，如果长时间没有分配 可能是匹配不到站点，建议更换其他快递。</strong></p>","title":"快递员不取件怎么办？","type":1,"creator":"yundiadmin"},{"id":"1721098537808302080","createTime":"2023-11-05 17:34:03","content":"<p><strong>建议自行包装好，以免额外产生包装费用。或您可以与快递小哥商议是否免费提供包装，下单后在运单查询页面会显示快递员联系方式。</strong></p>","title":"是否提供包装？","type":1,"creator":"yundiadmin"},{"id":"1721065622999273472","createTime":"2023-11-05 15:23:15","content":"<p><strong>查不到物流轨迹主要有以下原因：</strong></p><p><strong>1、因为订单刚刚寄出，快递信息尚未录入系统，需要等待一段时间。</strong></p><p><strong>2、运单号时间过久，单号过期无法查询。（一般过期时间在几个月左右）</strong></p><p><strong>如有其它情况查不到物流轨迹，可以咨询在线客服实时为您处理。</strong></p>","title":"为什么查不到物流轨迹呢？","type":1,"creator":"yundiadmin"},{"id":"1721098178725548032","createTime":"2023-11-05 17:32:37","content":"<p><strong>各快递情况不同，可以联系在线客服申请修改地址，但不确保会100%成功。</strong></p>","title":"可以修改地址吗？","type":1,"creator":"yundiadmin"},{"id":"1721100177634365440","createTime":"2023-11-05 17:40:34","content":"<p><strong>正常情况下，四点以前下单当天取件，四点以后下单第二天取件。</strong></p>","title":"快递员取件时间","type":1,"creator":"yundiadmin"},{"id":"1532714615610413056","createTime":"2022-06-03 21:23:35","content":"<p>1.计价逻辑：采用首续重计价方式；<br>2.计费重量：取体积重量与实际重量两者的较大值；[京东物流]体积重量=长(cm) x 宽(cm) x 高(cm) ÷8000<br>3.计费重量进位规则：重量不足1kg的，按1kg计算；<br>4.京东物流不保价最高赔付6倍运费，如未告知客户，出现赔偿代理后果自负！具体政策可咨询揽件快递员，易碎、贵重、生鲜、耗材、包装等会有额外政策价格请现成与快递员核实清楚。<br>5.所有渠道超出30公斤全票原价！部分渠道超出限制重量全票原价（可参考渠道名称显示限重重量）。<br>6.禁止揽收京东派范围内学校的件。<br>7.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。<br>8.重要提示：客户有任何售后问题，请务必联系八宝汇客服处理，不要联系京东官方！京东渠道禁止出现任何投诉，感谢理解！<br>9.京东禁止寄子母件，如寄出子母件，出现体积、重量异常，很难复议成功，需下单人自行承担运费。</p>","title":"京东快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532714698145927168","createTime":"2022-06-03 21:23:55","content":"<p>1. 产品定义<br/>1.1特快重货：主打20-100KG段重货，为客户提供安全便捷、高品质的点对点零担货物托运服务。<br/>1.2特快零担：主打100以上，为客户提供时效精准、安全可靠的零担货物托运服务。<br/>1.3特快重货送货上楼，特快零担不上楼。<br/><br/>2. 服务标准<br/>2.1服务概述：京东物流负责将货物送至客户指定目的地并进行交接的托运服务，含正向、逆向物流服务：<br/>①正向物流服务：是指京东物流接受客户委托后，将客户货物从指定提货地运送至指定目的地的物流服务。<br/>②逆向物流服务：是指正向发货的包裹，到达目的地后，因收件人无法联系上，或寄件人要求发起拦截包裹，导致包裹原路退回的物流服务。逆向物流费用跟正向物流收费标准一致。<br/>注意（非常重要）：如包裹已被揽收员揽收，寄件人不想寄了，这个会产生正向和逆向物流费用！务必提醒寄件人，一旦包裹被揽收，严禁拦截包裹，否则将产生正向及逆向两次的物流费用！<br/>2.2截单时间：各城市的截单时间一般在17:00—19:00，因城市不同会有差异，具体以实际为准。<br/>2.3服务时间：除节假日外，全年提供标准服务。<br/>2.4服务范围：上门接货地区以实际开通为准，到达地区为中国大陆全境，具体服务范围以官网查询为准。<br/>2.5价格模式：特快重货：首续重计费，按照计费重量计费，其中：轻泡货按照6000系数折算计费重量（计费重量=长×宽×高/6000，cm3）,具体收费标准可参见官网；<br/>特快零担：按计费重量计费，其中：轻泡货按照4800系数折算计费重量（计费重量=长×宽×高/4800，cm3），最低一票：70元起，具体收费标准可参见官网；<br/>多包裹体积计费按照取整计算，如长度为53，则按照60计算。<br/>3.1物品需要自行打包，如不打包，产生的费用，需要自行承担。贵重物品，打包时请拍照保存，以免发生理赔时无法提供有利的理赔证据。<br/>3.2包丢不包坏。如有损坏，请联系平台客服或者上级，禁止客户向京东投诉，渠道紧张，希望代理珍惜保护渠道<br/>3.3客户提供尺寸，仅供参考，具体实际尺寸以快递员测量为准，后期加木架，加托盘等，会使计费体积变大，费用增加，要和客户交代清楚</p>","title":"京东重货规则说明","type":1,"creator":"820682523800637440"},{"id":"1532714760850771968","createTime":"2022-06-03 21:24:10","content":"<p>1.计价逻辑：采用首续重计价方式，同区地址部分线路首重3kg起；<br>2.计费重量：取体积重量与实际重量两者的较大值；[德邦快递]体积重量=长(cm) x 宽(cm) x 高(cm) ÷6000<br>3.计费重量进位规则：重量不足1kg的，按1kg计算；<br>4.折扣价格进位规则：同区地址折扣后续重不满足1元，续重每kg按1元计算<br>5.德邦快递不保价不予理赔，保价价格4‰，具体政策可咨询揽件快递员；<br> &nbsp;易碎、贵重、生鲜、耗材、包装等会有额外政策价格，超长、超重、外发、退回等情形均会造成费用的增加，请与快递员核实清楚。<br>6.单个包裹限重60公斤（单个包裹超过60公斤原价），子母件最多可以1拖9（所以最高单票限重60*9=540公斤）。<br>7.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"德邦快递规则说明","type":1,"creator":"820682523800637440"},{"id":"1532714809840242688","createTime":"2022-06-03 21:24:22","content":"<p>1.计价逻辑：采用折扣计价方式；<br>2.快递类型：精准汽运，精准卡航，最低计费首重30kg起，送货上门不上楼，务必与寄件人收件人核实好<br>3.计费重量：取体积重量与实际重量两者的较大值；体积重量=长(cm) x 宽(cm) x 高(cm) ÷6000<br>4.计费重量进位规则：重量不足1kg的，按1kg计算；<br>5.折扣价格进位规则：同区地址折扣后续重不满足1元，续重每kg按1元计算<br>6.德邦物流不保价不予理赔，保价价格5‰-6‰，具体政策以渠道参数为准，或可咨询揽件快递员；<br> &nbsp;易碎、贵重、生鲜、耗材、包装等会有额外政策价格，超长、超重、外发、退回等情形均会造成费用的增加，请与快递员核实清楚。<br>7.以上计费规则可能会因不同产品或地区有所差异，更多详情可致电当地快递员咨询。</p>","title":"德邦重货规则说明","type":1,"creator":"820682523800637440"}]';
        return $this->success('', ['a' => json_decode($a, true), 'b' => json_decode($b, true)]);
    }
}
